/*
 * Class Name: SAICGUI
 * Funciton: To provide GUI for user to use SAIC easily
 * Author: Xuchu (Bella) HOU
 * Time:  Sep. 2012
 */


package edu.vt.cbil.ui;

import edu.vt.cbil.util.GeneDeletionInfo;
import edu.vt.cbil.util.Logger;
import edu.vt.cbil.util.DataConversion;
import edu.vt.cbil.util.GeneSet;
import edu.vt.cbil.saic.DetectSCAs;
import edu.vt.cbil.bacom.CorrectNormalContam;
import edu.vt.cbil.exceptions.EmptyStringException;
import edu.vt.cbil.exceptions.FileDoesNotExistException;
import edu.vt.cbil.exceptions.InvalidFormatException;
import edu.vt.cbil.exceptions.SampleSizeDoesNotMatchException;
import edu.vt.cbil.saic.AisaicPlot;
import static edu.vt.cbil.saic.AisaicPlot.createAisaicPlotObjectFromDataFiles;
import edu.vt.cbil.util.BacomParameters;
import edu.vt.cbil.util.SaicParameters;
import java.awt.Desktop;

import java.io.*;
import java.util.*;
import java.util.concurrent.*;
import javax.swing.*;
import javax.swing.filechooser.FileFilter;
import javax.swing.filechooser.FileNameExtensionFilter;


public class AisaicGUI extends javax.swing.JFrame {

    boolean bacomOnly = false;
    boolean saicOnly = false;
    boolean bacomAndsaic = false;  
    File currentDir;   
    SwingBACOM mySwingBACOM ;
    SwingSCAs mySwingSCAs ;
    SwingAISAIC mySwingAISAIC;
    BacomParameters bacomPara;
    SaicParameters saicPara;
    final String FIG_PATH = "." + File.separator + "results" + File.separator 
            + "figures" + File.separator;
 
    
    /** Creates new form SAICGUI */
    public AisaicGUI() {
        initComponents();
        jTextField6.setText("." + File.separator + "cdf" + File.separator + "GenomeWideSNP_6.cdf");
        jTextField9.setText("." + File.separator + "annotation" + File.separator + "GenomeWideSNP_6_Annotation.csv");
        jTextField4.setText("." + File.separator + "results");
        jTextField8.setText("." + File.separator + "gene_reference" + File.separator + "geneReference.gene");
        File figDir=new File(FIG_PATH);
        if(!figDir.exists()){
            figDir.mkdir();
        }
    }

    /** This method is called from within the constructor to
     * initialize the form.
     * WARNING: Do NOT modify this code. The content of this method is
     * always regenerated by the Form Editor.
     */
    @SuppressWarnings("unchecked")
    // <editor-fold defaultstate="collapsed" desc="Generated Code">//GEN-BEGIN:initComponents
    private void initComponents() {

        jDialogAbout = new javax.swing.JDialog();
        jLabel16 = new javax.swing.JLabel();
        jLabel17 = new javax.swing.JLabel();
        jLabel18 = new javax.swing.JLabel();
        jLabel19 = new javax.swing.JLabel();
        jLabel20 = new javax.swing.JLabel();
        jButton11 = new javax.swing.JButton();
        jButton3 = new javax.swing.JButton();
        jScrollPane2 = new javax.swing.JScrollPane();
        jTextArea2 = new javax.swing.JTextArea();
        Data1 = new javax.swing.JPanel();
        jLabel2 = new javax.swing.JLabel();
        jLabel4 = new javax.swing.JLabel();
        jTextField3 = new javax.swing.JTextField();
        jTextField4 = new javax.swing.JTextField();
        jButton4 = new javax.swing.JButton();
        jButton5 = new javax.swing.JButton();
        jLabel5 = new javax.swing.JLabel();
        jTextField5 = new javax.swing.JTextField();
        jButton6 = new javax.swing.JButton();
        jLabel6 = new javax.swing.JLabel();
        jTextField6 = new javax.swing.JTextField();
        jButton7 = new javax.swing.JButton();
        jComboBox1 = new javax.swing.JComboBox();
        jLabel7 = new javax.swing.JLabel();
        jLabel8 = new javax.swing.JLabel();
        jTextField7 = new javax.swing.JTextField();
        jLabel11 = new javax.swing.JLabel();
        jTextField9 = new javax.swing.JTextField();
        jButton10 = new javax.swing.JButton();
        Data = new javax.swing.JPanel();
        jLabel1 = new javax.swing.JLabel();
        jLabel3 = new javax.swing.JLabel();
        jTextField1 = new javax.swing.JTextField();
        jTextField2 = new javax.swing.JTextField();
        jButton1 = new javax.swing.JButton();
        jButton2 = new javax.swing.JButton();
        jTextField11 = new javax.swing.JTextField();
        jLabel12 = new javax.swing.JLabel();
        jTextField12 = new javax.swing.JTextField();
        jLabel13 = new javax.swing.JLabel();
        jTextField13 = new javax.swing.JTextField();
        jLabel14 = new javax.swing.JLabel();
        jTextField14 = new javax.swing.JTextField();
        jLabel15 = new javax.swing.JLabel();
        jRadioButton6 = new javax.swing.JRadioButton();
        jRadioButton7 = new javax.swing.JRadioButton();
        jLabel9 = new javax.swing.JLabel();
        jTextField8 = new javax.swing.JTextField();
        jButton8 = new javax.swing.JButton();
        jComboBox2 = new javax.swing.JComboBox();
        jLabel10 = new javax.swing.JLabel();
        jPanel1 = new javax.swing.JPanel();
        jRadioButton1 = new javax.swing.JRadioButton();
        jRadioButton2 = new javax.swing.JRadioButton();
        jRadioButton4 = new javax.swing.JRadioButton();
        jButton9 = new javax.swing.JButton();
        jMenuBar = new javax.swing.JMenuBar();
        jMenuFile = new javax.swing.JMenu();
        jMenuItemExit = new javax.swing.JMenuItem();
        jMenuView = new javax.swing.JMenu();
        jMenuItemSingleChrViz = new javax.swing.JMenuItem();
        jMenuItemGenomeWideViz = new javax.swing.JMenuItem();
        jMenuMultipleChrViz = new javax.swing.JMenu();
        jMenuItemChr1 = new javax.swing.JMenuItem();
        jMenuItemChr2 = new javax.swing.JMenuItem();
        jMenuItemChr3 = new javax.swing.JMenuItem();
        jMenuItemChr4 = new javax.swing.JMenuItem();
        jMenuItemChr5 = new javax.swing.JMenuItem();
        jMenuItemChr6 = new javax.swing.JMenuItem();
        jMenuItemChr7 = new javax.swing.JMenuItem();
        jMenuItemChr8 = new javax.swing.JMenuItem();
        jMenuItemChr9 = new javax.swing.JMenuItem();
        jMenuItemChr10 = new javax.swing.JMenuItem();
        jMenuItemChr11 = new javax.swing.JMenuItem();
        jMenuItemChr12 = new javax.swing.JMenuItem();
        jMenuItemChr13 = new javax.swing.JMenuItem();
        jMenuItemChr14 = new javax.swing.JMenuItem();
        jMenuItemChr15 = new javax.swing.JMenuItem();
        jMenuItemChr16 = new javax.swing.JMenuItem();
        jMenuItemChr17 = new javax.swing.JMenuItem();
        jMenuItemChr18 = new javax.swing.JMenuItem();
        jMenuItemChr19 = new javax.swing.JMenuItem();
        jMenuItemChr20 = new javax.swing.JMenuItem();
        jMenuItemChr21 = new javax.swing.JMenuItem();
        jMenuItemChr22 = new javax.swing.JMenuItem();
        JMenuHelp = new javax.swing.JMenu();
        jMenuItemAbout = new javax.swing.JMenuItem();

        jDialogAbout.setAlwaysOnTop(true);
        jDialogAbout.setMinimumSize(new java.awt.Dimension(400, 300));
        jDialogAbout.setModal(true);
        jDialogAbout.setName("About"); // NOI18N

        jLabel16.setText("Version: v1.0");

        jLabel17.setText("License: BSD");

        jLabel18.setText("Contact: CBIL, ECE, Virginia Tech");

        jLabel19.setText("Thank you for using AISAIC!");

        jLabel20.setText("URL: www.cbil.ece.vt.edu");

        jButton11.setText("OK");
        jButton11.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                jButton11ActionPerformed(evt);
            }
        });

        javax.swing.GroupLayout jDialogAboutLayout = new javax.swing.GroupLayout(jDialogAbout.getContentPane());
        jDialogAbout.getContentPane().setLayout(jDialogAboutLayout);
        jDialogAboutLayout.setHorizontalGroup(
            jDialogAboutLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(jDialogAboutLayout.createSequentialGroup()
                .addGap(133, 133, 133)
                .addComponent(jButton11, javax.swing.GroupLayout.PREFERRED_SIZE, 95, javax.swing.GroupLayout.PREFERRED_SIZE)
                .addContainerGap(javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE))
            .addGroup(javax.swing.GroupLayout.Alignment.TRAILING, jDialogAboutLayout.createSequentialGroup()
                .addContainerGap(64, Short.MAX_VALUE)
                .addGroup(jDialogAboutLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING, false)
                    .addComponent(jLabel20, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
                    .addComponent(jLabel19, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
                    .addComponent(jLabel18, javax.swing.GroupLayout.PREFERRED_SIZE, 309, javax.swing.GroupLayout.PREFERRED_SIZE)
                    .addComponent(jLabel17, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
                    .addComponent(jLabel16, javax.swing.GroupLayout.PREFERRED_SIZE, 324, javax.swing.GroupLayout.PREFERRED_SIZE))
                .addContainerGap())
        );
        jDialogAboutLayout.setVerticalGroup(
            jDialogAboutLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(jDialogAboutLayout.createSequentialGroup()
                .addContainerGap(39, Short.MAX_VALUE)
                .addComponent(jLabel19, javax.swing.GroupLayout.PREFERRED_SIZE, 30, javax.swing.GroupLayout.PREFERRED_SIZE)
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                .addComponent(jLabel16, javax.swing.GroupLayout.PREFERRED_SIZE, 29, javax.swing.GroupLayout.PREFERRED_SIZE)
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                .addComponent(jLabel17, javax.swing.GroupLayout.PREFERRED_SIZE, 29, javax.swing.GroupLayout.PREFERRED_SIZE)
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                .addComponent(jLabel18, javax.swing.GroupLayout.PREFERRED_SIZE, 28, javax.swing.GroupLayout.PREFERRED_SIZE)
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                .addComponent(jLabel20, javax.swing.GroupLayout.PREFERRED_SIZE, 27, javax.swing.GroupLayout.PREFERRED_SIZE)
                .addGap(34, 34, 34)
                .addComponent(jButton11, javax.swing.GroupLayout.PREFERRED_SIZE, 30, javax.swing.GroupLayout.PREFERRED_SIZE)
                .addGap(30, 30, 30))
        );

        setDefaultCloseOperation(javax.swing.WindowConstants.EXIT_ON_CLOSE);
        setTitle("AISAIC: Accurate Identification of Significant Copy Number Aberrations in Cancer Genome");
        setBackground(new java.awt.Color(255, 255, 255));

        jButton3.setText("Start");
        jButton3.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                jButton3ActionPerformed(evt);
            }
        });

        jTextArea2.setEditable(false);
        jTextArea2.setColumns(20);
        jTextArea2.setRows(5);
        jTextArea2.setBorder(javax.swing.BorderFactory.createTitledBorder(null, "Processing Status", javax.swing.border.TitledBorder.DEFAULT_JUSTIFICATION, javax.swing.border.TitledBorder.DEFAULT_POSITION, new java.awt.Font("Georgia", 1, 12), new java.awt.Color(0, 102, 102))); // NOI18N
        jScrollPane2.setViewportView(jTextArea2);

        Data1.setBorder(javax.swing.BorderFactory.createTitledBorder(javax.swing.BorderFactory.createTitledBorder(null, "", javax.swing.border.TitledBorder.DEFAULT_JUSTIFICATION, javax.swing.border.TitledBorder.DEFAULT_POSITION, new java.awt.Font("Georgia", 1, 12), new java.awt.Color(0, 102, 102)), "BACOM Module", javax.swing.border.TitledBorder.DEFAULT_JUSTIFICATION, javax.swing.border.TitledBorder.DEFAULT_POSITION, new java.awt.Font("Georgia", 1, 12), new java.awt.Color(0, 102, 102))); // NOI18N
        Data1.setName("SAIC "); // NOI18N

        jLabel2.setFont(new java.awt.Font("Tahoma", 0, 12)); // NOI18N
        jLabel2.setText("Input normal sample:");

        jLabel4.setFont(new java.awt.Font("Tahoma", 0, 12)); // NOI18N
        jLabel4.setText("BACOM result folder:");

        jTextField3.setMaximumSize(new java.awt.Dimension(6, 20));
        jTextField3.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                jTextField3ActionPerformed(evt);
            }
        });

        jTextField4.setMaximumSize(new java.awt.Dimension(6, 20));
        jTextField4.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                jTextField4ActionPerformed(evt);
            }
        });

        jButton4.setText("...");
        jButton4.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                jButton4ActionPerformed(evt);
            }
        });

        jButton5.setText("...");
        jButton5.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                jButton5ActionPerformed(evt);
            }
        });

        jLabel5.setFont(new java.awt.Font("Tahoma", 0, 12)); // NOI18N
        jLabel5.setText("Paired tumor sample:");

        jTextField5.setMaximumSize(new java.awt.Dimension(6, 20));
        jTextField5.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                jTextField5ActionPerformed(evt);
            }
        });

        jButton6.setText("...");
        jButton6.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                jButton6ActionPerformed(evt);
            }
        });

        jLabel6.setFont(new java.awt.Font("Tahoma", 0, 12)); // NOI18N
        jLabel6.setText("CDF file:");

        jTextField6.setMaximumSize(new java.awt.Dimension(6, 20));
        jTextField6.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                jTextField6ActionPerformed(evt);
            }
        });

        jButton7.setText("...");
        jButton7.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                jButton7ActionPerformed(evt);
            }
        });

        jComboBox1.setModel(new javax.swing.DefaultComboBoxModel(new String[] { "Single sample analysis", "Multiple samples analysis" }));
        jComboBox1.setCursor(new java.awt.Cursor(java.awt.Cursor.DEFAULT_CURSOR));
        jComboBox1.setMaximumSize(new java.awt.Dimension(138, 18));
        jComboBox1.setPreferredSize(new java.awt.Dimension(138, 18));
        jComboBox1.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                jComboBox1ActionPerformed(evt);
            }
        });

        jLabel7.setFont(new java.awt.Font("Tahoma", 0, 12)); // NOI18N
        jLabel7.setText("Analysis Mode:");

        jLabel8.setFont(new java.awt.Font("Tahoma", 0, 12)); // NOI18N
        jLabel8.setText("Genomic region interested:");

        jTextField7.setText("10:122256455-135274086");
        jTextField7.setMaximumSize(new java.awt.Dimension(6, 20));
        jTextField7.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                jTextField7ActionPerformed(evt);
            }
        });

        jLabel11.setFont(new java.awt.Font("Tahoma", 0, 12)); // NOI18N
        jLabel11.setText("Annotation file:");

        jTextField9.setMaximumSize(new java.awt.Dimension(6, 20));
        jTextField9.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                jTextField9ActionPerformed(evt);
            }
        });

        jButton10.setText("...");
        jButton10.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                jButton10ActionPerformed(evt);
            }
        });

        Data.setBorder(javax.swing.BorderFactory.createTitledBorder(javax.swing.BorderFactory.createTitledBorder(null, "", javax.swing.border.TitledBorder.DEFAULT_JUSTIFICATION, javax.swing.border.TitledBorder.DEFAULT_POSITION, new java.awt.Font("Georgia", 1, 12), new java.awt.Color(0, 102, 102)), "SAIC Module", javax.swing.border.TitledBorder.DEFAULT_JUSTIFICATION, javax.swing.border.TitledBorder.DEFAULT_POSITION, new java.awt.Font("Georgia", 1, 12), new java.awt.Color(0, 102, 102))); // NOI18N
        Data.setName("SAIC "); // NOI18N

        jLabel1.setFont(new java.awt.Font("Tahoma", 0, 12)); // NOI18N
        jLabel1.setText("Input segmented CNA data:");

        jLabel3.setFont(new java.awt.Font("Tahoma", 0, 12)); // NOI18N
        jLabel3.setText("SAIC detection result folder:");

        jTextField1.setMaximumSize(new java.awt.Dimension(6, 20));
        jTextField1.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                jTextField1ActionPerformed(evt);
            }
        });

        jTextField2.setMaximumSize(new java.awt.Dimension(6, 20));
        jTextField2.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                jTextField2ActionPerformed(evt);
            }
        });

        jButton1.setText("...");
        jButton1.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                jButton1ActionPerformed(evt);
            }
        });

        jButton2.setText("...");
        jButton2.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                jButton2ActionPerformed(evt);
            }
        });

        jTextField11.setText("0.322");
        jTextField11.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                jTextField11ActionPerformed(evt);
            }
        });

        jLabel12.setFont(new java.awt.Font("Tahoma", 0, 12)); // NOI18N
        jLabel12.setText("Log-ratio amplification threshold (Default 0.322)");

        jTextField12.setText("-0.415");
        jTextField12.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                jTextField12ActionPerformed(evt);
            }
        });

        jLabel13.setFont(new java.awt.Font("Tahoma", 0, 12)); // NOI18N
        jLabel13.setText("Log-ratio deletion threshold (Default -0.415)");

        jTextField13.setText("1000");
        jTextField13.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                jTextField13ActionPerformed(evt);
            }
        });

        jLabel14.setFont(new java.awt.Font("Tahoma", 0, 12)); // NOI18N
        jLabel14.setText("Number of permutation (Default 1000)");

        jTextField14.setText("0.9");
        jTextField14.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                jTextField14ActionPerformed(evt);
            }
        });

        jLabel15.setFont(new java.awt.Font("Tahoma", 0, 12)); // NOI18N
        jLabel15.setText("Correlation coefficient threshold (Default 0.9)");

        jRadioButton6.setSelected(true);
        jRadioButton6.setText("Adopt SCA-excluding permutation scheme");
        jRadioButton6.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                jRadioButton6ActionPerformed(evt);
            }
        });

        jRadioButton7.setSelected(true);
        jRadioButton7.setText("Adopt quick SAIC");
        jRadioButton7.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                jRadioButton7ActionPerformed(evt);
            }
        });

        jLabel9.setFont(new java.awt.Font("Tahoma", 0, 12)); // NOI18N
        jLabel9.setText("Gene reference file:");

        jTextField8.setText("./gene_reference/geneReference.gene");
        jTextField8.setMaximumSize(new java.awt.Dimension(6, 20));
        jTextField8.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                jTextField8ActionPerformed(evt);
            }
        });

        jButton8.setText("...");
        jButton8.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                jButton8ActionPerformed(evt);
            }
        });

        jComboBox2.setModel(new javax.swing.DefaultComboBoxModel(new String[] { "Single chromosome analysis", "Multiple chromosomes analysis", "Genome-wide analysis" }));
        jComboBox2.setMaximumSize(new java.awt.Dimension(225, 18));
        jComboBox2.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                jComboBox2ActionPerformed(evt);
            }
        });

        jLabel10.setFont(new java.awt.Font("Tahoma", 0, 12)); // NOI18N
        jLabel10.setText("Analysis Mode:");

        javax.swing.GroupLayout DataLayout = new javax.swing.GroupLayout(Data);
        Data.setLayout(DataLayout);
        DataLayout.setHorizontalGroup(
            DataLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(DataLayout.createSequentialGroup()
                .addContainerGap()
                .addGroup(DataLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                    .addGroup(DataLayout.createSequentialGroup()
                        .addComponent(jTextField12, javax.swing.GroupLayout.PREFERRED_SIZE, 58, javax.swing.GroupLayout.PREFERRED_SIZE)
                        .addGap(18, 18, 18)
                        .addComponent(jLabel13, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
                        .addContainerGap())
                    .addGroup(DataLayout.createSequentialGroup()
                        .addComponent(jTextField13, javax.swing.GroupLayout.PREFERRED_SIZE, 58, javax.swing.GroupLayout.PREFERRED_SIZE)
                        .addGap(18, 18, 18)
                        .addComponent(jLabel14, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
                        .addContainerGap())
                    .addGroup(javax.swing.GroupLayout.Alignment.TRAILING, DataLayout.createSequentialGroup()
                        .addComponent(jTextField14, javax.swing.GroupLayout.PREFERRED_SIZE, 58, javax.swing.GroupLayout.PREFERRED_SIZE)
                        .addGap(18, 18, 18)
                        .addComponent(jLabel15, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
                        .addGap(2, 2, 2))
                    .addGroup(DataLayout.createSequentialGroup()
                        .addGroup(DataLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                            .addGroup(DataLayout.createSequentialGroup()
                                .addGap(42, 42, 42)
                                .addComponent(jRadioButton6)
                                .addGap(161, 161, 161)
                                .addComponent(jRadioButton7, javax.swing.GroupLayout.PREFERRED_SIZE, 155, javax.swing.GroupLayout.PREFERRED_SIZE))
                            .addGroup(DataLayout.createSequentialGroup()
                                .addComponent(jTextField11, javax.swing.GroupLayout.PREFERRED_SIZE, 58, javax.swing.GroupLayout.PREFERRED_SIZE)
                                .addGap(18, 18, 18)
                                .addComponent(jLabel12, javax.swing.GroupLayout.PREFERRED_SIZE, 346, javax.swing.GroupLayout.PREFERRED_SIZE)))
                        .addGap(0, 0, Short.MAX_VALUE))
                    .addGroup(DataLayout.createSequentialGroup()
                        .addGroup(DataLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                            .addGroup(DataLayout.createSequentialGroup()
                                .addGroup(DataLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                                    .addComponent(jLabel3)
                                    .addComponent(jLabel9))
                                .addGap(18, 18, 18)
                                .addGroup(DataLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                                    .addComponent(jTextField2, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
                                    .addComponent(jTextField8, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)))
                            .addGroup(DataLayout.createSequentialGroup()
                                .addGroup(DataLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                                    .addComponent(jLabel1)
                                    .addComponent(jLabel10))
                                .addGap(18, 18, 18)
                                .addGroup(DataLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                                    .addComponent(jComboBox2, javax.swing.GroupLayout.PREFERRED_SIZE, 267, javax.swing.GroupLayout.PREFERRED_SIZE)
                                    .addComponent(jTextField1, javax.swing.GroupLayout.PREFERRED_SIZE, 549, javax.swing.GroupLayout.PREFERRED_SIZE))
                                .addGap(0, 0, Short.MAX_VALUE)))
                        .addGroup(DataLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                            .addGroup(DataLayout.createSequentialGroup()
                                .addGap(27, 27, 27)
                                .addGroup(DataLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                                    .addComponent(jButton2, javax.swing.GroupLayout.Alignment.TRAILING)
                                    .addComponent(jButton1, javax.swing.GroupLayout.Alignment.TRAILING)))
                            .addGroup(javax.swing.GroupLayout.Alignment.TRAILING, DataLayout.createSequentialGroup()
                                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                                .addComponent(jButton8)))
                        .addContainerGap())))
        );
        DataLayout.setVerticalGroup(
            DataLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(DataLayout.createSequentialGroup()
                .addContainerGap(javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
                .addGroup(DataLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                    .addComponent(jComboBox2, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
                    .addComponent(jLabel10))
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                .addGroup(DataLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                    .addComponent(jLabel1)
                    .addComponent(jTextField1, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
                    .addComponent(jButton2))
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                .addGroup(DataLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                    .addComponent(jLabel3)
                    .addComponent(jTextField2, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
                    .addComponent(jButton1))
                .addGap(5, 5, 5)
                .addGroup(DataLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                    .addComponent(jLabel9)
                    .addComponent(jTextField8, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
                    .addComponent(jButton8))
                .addGap(10, 10, 10)
                .addGroup(DataLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                    .addComponent(jTextField11, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
                    .addComponent(jLabel12, javax.swing.GroupLayout.PREFERRED_SIZE, 19, javax.swing.GroupLayout.PREFERRED_SIZE))
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                .addGroup(DataLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                    .addComponent(jTextField12, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
                    .addComponent(jLabel13))
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                .addGroup(DataLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                    .addComponent(jTextField13, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
                    .addComponent(jLabel14))
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                .addGroup(DataLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                    .addComponent(jTextField14, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
                    .addComponent(jLabel15))
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.UNRELATED)
                .addGroup(DataLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                    .addComponent(jRadioButton6)
                    .addComponent(jRadioButton7)))
        );

        javax.swing.GroupLayout Data1Layout = new javax.swing.GroupLayout(Data1);
        Data1.setLayout(Data1Layout);
        Data1Layout.setHorizontalGroup(
            Data1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(Data1Layout.createSequentialGroup()
                .addContainerGap()
                .addGroup(Data1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                    .addGroup(Data1Layout.createSequentialGroup()
                        .addGroup(Data1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                            .addGroup(Data1Layout.createSequentialGroup()
                                .addGroup(Data1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                                    .addComponent(jLabel2)
                                    .addComponent(jLabel7))
                                .addGap(54, 54, 54)
                                .addComponent(jComboBox1, javax.swing.GroupLayout.PREFERRED_SIZE, 279, javax.swing.GroupLayout.PREFERRED_SIZE)
                                .addGap(0, 0, Short.MAX_VALUE))
                            .addGroup(Data1Layout.createSequentialGroup()
                                .addGroup(Data1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                                    .addComponent(jLabel8)
                                    .addComponent(jLabel6)
                                    .addComponent(jLabel5))
                                .addGroup(Data1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                                    .addGroup(Data1Layout.createSequentialGroup()
                                        .addGap(20, 20, 20)
                                        .addGroup(Data1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                                            .addComponent(jTextField6, javax.swing.GroupLayout.Alignment.TRAILING, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
                                            .addComponent(jTextField5, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
                                            .addComponent(jTextField9, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
                                            .addComponent(jTextField3, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)))
                                    .addGroup(Data1Layout.createSequentialGroup()
                                        .addGap(18, 18, 18)
                                        .addComponent(jTextField4, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE))
                                    .addGroup(Data1Layout.createSequentialGroup()
                                        .addGap(18, 18, 18)
                                        .addComponent(jTextField7, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)))))
                        .addGap(15, 15, 15))
                    .addGroup(Data1Layout.createSequentialGroup()
                        .addGroup(Data1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                            .addComponent(jLabel11)
                            .addComponent(jLabel4))
                        .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)))
                .addGroup(Data1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.TRAILING)
                    .addComponent(jButton4)
                    .addComponent(jButton6)
                    .addComponent(jButton7)
                    .addComponent(jButton10)
                    .addComponent(jButton5))
                .addGap(17, 17, 17))
            .addComponent(Data, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
        );
        Data1Layout.setVerticalGroup(
            Data1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(Data1Layout.createSequentialGroup()
                .addGap(3, 3, 3)
                .addGroup(Data1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                    .addComponent(jComboBox1, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
                    .addComponent(jLabel7))
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                .addGroup(Data1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                    .addComponent(jLabel2)
                    .addComponent(jTextField3, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
                    .addComponent(jButton6))
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                .addGroup(Data1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                    .addComponent(jTextField5, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
                    .addComponent(jButton4)
                    .addComponent(jLabel5))
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                .addGroup(Data1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                    .addComponent(jTextField6, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
                    .addComponent(jLabel6)
                    .addComponent(jButton7))
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                .addGroup(Data1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                    .addComponent(jLabel11)
                    .addComponent(jTextField9, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
                    .addComponent(jButton10))
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
                .addGroup(Data1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                    .addComponent(jLabel4)
                    .addComponent(jTextField4, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
                    .addComponent(jButton5))
                .addGap(4, 4, 4)
                .addGroup(Data1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                    .addComponent(jLabel8, javax.swing.GroupLayout.PREFERRED_SIZE, 22, javax.swing.GroupLayout.PREFERRED_SIZE)
                    .addComponent(jTextField7, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE))
                .addGap(18, 18, 18)
                .addComponent(Data, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
                .addContainerGap())
        );

        jPanel1.setBorder(javax.swing.BorderFactory.createTitledBorder(null, "Analysis Selection", javax.swing.border.TitledBorder.DEFAULT_JUSTIFICATION, javax.swing.border.TitledBorder.DEFAULT_POSITION, new java.awt.Font("Georgia", 1, 12), new java.awt.Color(0, 102, 102))); // NOI18N

        jRadioButton1.setText("BACOM ONLY");
        jRadioButton1.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                jRadioButton1ActionPerformed(evt);
            }
        });

        jRadioButton2.setText("SAIC ONLY");
        jRadioButton2.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                jRadioButton2ActionPerformed(evt);
            }
        });

        jRadioButton4.setText("BACOM+SAIC");
        jRadioButton4.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                jRadioButton4ActionPerformed(evt);
            }
        });

        javax.swing.GroupLayout jPanel1Layout = new javax.swing.GroupLayout(jPanel1);
        jPanel1.setLayout(jPanel1Layout);
        jPanel1Layout.setHorizontalGroup(
            jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(jPanel1Layout.createSequentialGroup()
                .addContainerGap()
                .addComponent(jRadioButton1)
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
                .addComponent(jRadioButton2)
                .addGap(234, 234, 234)
                .addComponent(jRadioButton4)
                .addGap(24, 24, 24))
        );
        jPanel1Layout.setVerticalGroup(
            jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(jPanel1Layout.createSequentialGroup()
                .addContainerGap(javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
                .addGroup(jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                    .addComponent(jRadioButton1)
                    .addComponent(jRadioButton2, javax.swing.GroupLayout.PREFERRED_SIZE, 22, javax.swing.GroupLayout.PREFERRED_SIZE)
                    .addComponent(jRadioButton4)))
        );

        jButton9.setText("Stop");
        jButton9.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                jButton9ActionPerformed(evt);
            }
        });

        jMenuFile.setText("File");

        jMenuItemExit.setText("Exit");
        jMenuItemExit.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                jMenuItemExitActionPerformed(evt);
            }
        });
        jMenuFile.add(jMenuItemExit);

        jMenuBar.add(jMenuFile);

        jMenuView.setText("Visualization");

        jMenuItemSingleChrViz.setText("Single chromosome analysis");
        jMenuItemSingleChrViz.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                jMenuItemSingleChrVizActionPerformed(evt);
            }
        });
        jMenuView.add(jMenuItemSingleChrViz);

        jMenuItemGenomeWideViz.setText("Genome-wide analysis");
        jMenuItemGenomeWideViz.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                jMenuItemGenomeWideVizActionPerformed(evt);
            }
        });
        jMenuView.add(jMenuItemGenomeWideViz);

        jMenuMultipleChrViz.setText("Multiple chromosomes analysis");

        jMenuItemChr1.setText("Chromosome 1");
        jMenuItemChr1.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                jMenuItemChr1ActionPerformed(evt);
            }
        });
        jMenuMultipleChrViz.add(jMenuItemChr1);

        jMenuItemChr2.setText("Chromosome 2");
        jMenuItemChr2.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                jMenuItemChr2ActionPerformed(evt);
            }
        });
        jMenuMultipleChrViz.add(jMenuItemChr2);

        jMenuItemChr3.setText("Chromosome 3");
        jMenuItemChr3.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                jMenuItemChr3ActionPerformed(evt);
            }
        });
        jMenuMultipleChrViz.add(jMenuItemChr3);

        jMenuItemChr4.setText("Chromosome 4");
        jMenuItemChr4.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                jMenuItemChr4ActionPerformed(evt);
            }
        });
        jMenuMultipleChrViz.add(jMenuItemChr4);

        jMenuItemChr5.setText("Chromosome 5");
        jMenuItemChr5.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                jMenuItemChr5ActionPerformed(evt);
            }
        });
        jMenuMultipleChrViz.add(jMenuItemChr5);

        jMenuItemChr6.setText("Chromosome 6");
        jMenuItemChr6.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                jMenuItemChr6ActionPerformed(evt);
            }
        });
        jMenuMultipleChrViz.add(jMenuItemChr6);

        jMenuItemChr7.setText("Chromosome 7");
        jMenuItemChr7.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                jMenuItemChr7ActionPerformed(evt);
            }
        });
        jMenuMultipleChrViz.add(jMenuItemChr7);

        jMenuItemChr8.setText("Chromosome 8");
        jMenuItemChr8.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                jMenuItemChr8ActionPerformed(evt);
            }
        });
        jMenuMultipleChrViz.add(jMenuItemChr8);

        jMenuItemChr9.setText("Chromosome 9");
        jMenuItemChr9.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                jMenuItemChr9ActionPerformed(evt);
            }
        });
        jMenuMultipleChrViz.add(jMenuItemChr9);

        jMenuItemChr10.setText("Chromosome 10");
        jMenuItemChr10.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                jMenuItemChr10ActionPerformed(evt);
            }
        });
        jMenuMultipleChrViz.add(jMenuItemChr10);

        jMenuItemChr11.setText("Chromosome 11");
        jMenuItemChr11.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                jMenuItemChr11ActionPerformed(evt);
            }
        });
        jMenuMultipleChrViz.add(jMenuItemChr11);

        jMenuItemChr12.setText("Chromosome 12");
        jMenuItemChr12.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                jMenuItemChr12ActionPerformed(evt);
            }
        });
        jMenuMultipleChrViz.add(jMenuItemChr12);

        jMenuItemChr13.setText("Chromosome 13");
        jMenuItemChr13.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                jMenuItemChr13ActionPerformed(evt);
            }
        });
        jMenuMultipleChrViz.add(jMenuItemChr13);

        jMenuItemChr14.setText("Chromosome 14");
        jMenuItemChr14.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                jMenuItemChr14ActionPerformed(evt);
            }
        });
        jMenuMultipleChrViz.add(jMenuItemChr14);

        jMenuItemChr15.setText("Chromosome 15");
        jMenuItemChr15.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                jMenuItemChr15ActionPerformed(evt);
            }
        });
        jMenuMultipleChrViz.add(jMenuItemChr15);

        jMenuItemChr16.setText("Chromosome 16");
        jMenuItemChr16.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                jMenuItemChr16ActionPerformed(evt);
            }
        });
        jMenuMultipleChrViz.add(jMenuItemChr16);

        jMenuItemChr17.setText("Chromosome 17");
        jMenuItemChr17.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                jMenuItemChr17ActionPerformed(evt);
            }
        });
        jMenuMultipleChrViz.add(jMenuItemChr17);

        jMenuItemChr18.setText("Chromosome 18");
        jMenuItemChr18.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                jMenuItemChr18ActionPerformed(evt);
            }
        });
        jMenuMultipleChrViz.add(jMenuItemChr18);

        jMenuItemChr19.setText("Chromosome 19");
        jMenuItemChr19.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                jMenuItemChr19ActionPerformed(evt);
            }
        });
        jMenuMultipleChrViz.add(jMenuItemChr19);

        jMenuItemChr20.setText("Chromosome 20");
        jMenuItemChr20.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                jMenuItemChr20ActionPerformed(evt);
            }
        });
        jMenuMultipleChrViz.add(jMenuItemChr20);

        jMenuItemChr21.setText("Chromosome 21");
        jMenuItemChr21.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                jMenuItemChr21ActionPerformed(evt);
            }
        });
        jMenuMultipleChrViz.add(jMenuItemChr21);

        jMenuItemChr22.setText("Chromosome 22");
        jMenuItemChr22.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                jMenuItemChr22ActionPerformed(evt);
            }
        });
        jMenuMultipleChrViz.add(jMenuItemChr22);

        jMenuView.add(jMenuMultipleChrViz);

        jMenuBar.add(jMenuView);

        JMenuHelp.setText("Help");

        jMenuItemAbout.setText("About");
        jMenuItemAbout.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                jMenuItemAboutActionPerformed(evt);
            }
        });
        JMenuHelp.add(jMenuItemAbout);

        jMenuBar.add(JMenuHelp);

        setJMenuBar(jMenuBar);

        javax.swing.GroupLayout layout = new javax.swing.GroupLayout(getContentPane());
        getContentPane().setLayout(layout);
        layout.setHorizontalGroup(
            layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addComponent(jPanel1, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
            .addComponent(Data1, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
            .addGroup(layout.createSequentialGroup()
                .addContainerGap()
                .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                    .addGroup(javax.swing.GroupLayout.Alignment.TRAILING, layout.createSequentialGroup()
                        .addGap(0, 0, Short.MAX_VALUE)
                        .addComponent(jButton3)
                        .addGap(35, 35, 35)
                        .addComponent(jButton9)
                        .addGap(377, 377, 377))
                    .addComponent(jScrollPane2)))
        );
        layout.setVerticalGroup(
            layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(layout.createSequentialGroup()
                .addContainerGap()
                .addComponent(jPanel1, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                .addComponent(Data1, javax.swing.GroupLayout.PREFERRED_SIZE, 533, javax.swing.GroupLayout.PREFERRED_SIZE)
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.UNRELATED)
                .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                    .addComponent(jButton3)
                    .addComponent(jButton9))
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.UNRELATED)
                .addComponent(jScrollPane2, javax.swing.GroupLayout.PREFERRED_SIZE, 148, javax.swing.GroupLayout.PREFERRED_SIZE)
                .addContainerGap(44, Short.MAX_VALUE))
        );

        pack();
    }// </editor-fold>//GEN-END:initComponents

    private void jButton3ActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_jButton3ActionPerformed
       
        boolean errorFlag = false;
        jButton3.setEnabled(false);
        jButton9.setEnabled(true);          
        if (bacomOnly && !errorFlag)   
        {     
            bacomPara = new BacomParameters();
            if (jTextField3.getText().isEmpty() || jTextField4.getText().isEmpty() 
                         || jTextField5.getText().isEmpty() || jTextField6.getText().isEmpty())            {                
                jTextArea2.append("Please Select input/output/cdf file" + "\n" + "\n");
                jButton3.setEnabled(true);
                errorFlag = true;
            }  
            try{                
                bacomPara.setGeneInterested(jTextField7.getText().trim());
            }
            catch (InvalidFormatException e){
                jTextArea2.append("Invalid gene format, please follow this example: '10:123456-456789' " + "\n" + "\n");  
                jButton3.setEnabled(true);
                errorFlag = true;                
            }
            catch (EmptyStringException e2){
                bacomPara.setGeneInterestedNull();
            }
            
            if (!errorFlag)
            {   
                mySwingBACOM = new SwingBACOM();
                mySwingBACOM.execute();    
            }
        }
        
        else if (saicOnly && !errorFlag)
        {            
            // Check input and output
            saicPara = new SaicParameters();
            if (jTextField1.getText().isEmpty() || jTextField1.getText().isEmpty() )
            {                
                jTextArea2.append("Please Select input/output file" + "\n" + "\n");
                errorFlag = true;
                jButton3.setEnabled(true);
            }                
            // Check the parameters//
            try 
            {
                double  ta = Double.parseDouble(jTextField11.getText());
           
                if (ta<0)
                {
                    jTextArea2.append("Please type in a positive float number for threshold of copy number amplification" + "\n" + "\n");                    
                    jTextField11.setText("");                    
                    errorFlag = true;
                    jButton3.setEnabled(true);
                }
             }
            catch (NumberFormatException e)
            {
                jTextArea2.append("Please type in a positive float number for threshold of copy number amplification"
                                               + "\n" + "\n");
                jTextField11.setText("");
                jButton3.setEnabled(true);
                errorFlag = true;
            }
       
            try 
            {
                double td = Double.parseDouble(jTextField12.getText());
                if (td>0)
                {
                    jTextArea2.append("Please type in a negative float number for threshold of copy number deletion" 
                                               + "\n" + "\n");
                    jTextField12.setText("");
                    jButton3.setEnabled(true);
                    errorFlag = true;
                }
            }
            catch (NumberFormatException e)
            {
                jTextArea2.append("Please type in a negative float number for threshold of copy number deletion" 
                                               + "\n" + "\n");
                jTextField12.setText("");
                jButton3.setEnabled(true);
                errorFlag = true;
            }
            
            try 
            {
                double np = Integer.parseInt(jTextField13.getText());
             
                if (np<0)
                {
                    jTextArea2.append("Please type in a positive integer number for number of permutation"
                                              + "\n"+ "\n");
                    jTextField13.setText("");
                    jButton3.setEnabled(true);
                    errorFlag = true;
                }
            }
            catch (NumberFormatException e)
            {
                jTextArea2.append("Please type in a positive integer number for number of permutation"
                                              + "\n"+ "\n");
                jTextField13.setText("");
                jButton3.setEnabled(true);
                errorFlag = true;
            }        
            
            try 
            {
                double tc = Double.parseDouble(jTextField14.getText());
             
                if (tc>1 || tc<0)
                {
                    jTextArea2.append("Please type in a float number between 0 and 1 for correlation coefficient" 
                                              + "\n"+ "\n");
                    jTextField14.setText("");
                    jButton3.setEnabled(true);
                    errorFlag = true;
                }
            }
            catch (NumberFormatException e)
            {
                jTextArea2.append("Please type in a float number between 0 and 1 for correlation coefficient"
                                              + "\n"+ "\n");
                jTextField14.setText("");
                jButton3.setEnabled(true); 
                errorFlag = true;
            }  
            
            if (!errorFlag)
            {   
                mySwingSCAs = new SwingSCAs();
                mySwingSCAs.execute();         
            }
        }
        
        else if (bacomAndsaic && !errorFlag)
        {
            // Check the parameters for BACOM //
            bacomPara = new BacomParameters();
            saicPara = new SaicParameters();
            
            if (jTextField3.getText().isEmpty() || jTextField4.getText().isEmpty() 
                           || jTextField5.getText().isEmpty() || jTextField6.getText().isEmpty() )
                
            {                
                jTextArea2.append("Please select input/output/cdf file" + "\n" + "\n");
                errorFlag = true;
                jButton3.setEnabled(true);
            }
            try{                
                bacomPara.setGeneInterested(jTextField7.getText().trim());
            }
            catch (InvalidFormatException e){
                jTextArea2.append("Invalid gene format, please follow this example: '10:123456-456789' " + "\n" + "\n");  
                jButton3.setEnabled(true); 
                errorFlag = true;                
            }
            catch (EmptyStringException e2){
                bacomPara.setGeneInterestedNull();
            }
             
            // Check the parameters for SAIC//
            try 
            {
                double  ta = Double.parseDouble(jTextField11.getText());
           
                if (ta<0)
                {
                    jTextArea2.append("Please type in a positive float number for threshold of copy number amplification"
                                               + "\n" + "\n");                    
                    jTextField11.setText("");
                    jButton3.setEnabled(true); 
                    errorFlag = true;
                }
             }
            catch (NumberFormatException e)
            {
                jTextArea2.append("Please type in a positive float number for threshold of copy number amplification"
                                               + "\n" + "\n");
                jTextField11.setText("");
                jButton3.setEnabled(true);
                errorFlag = true;
            }
              
            try 
            {
                double td = Double.parseDouble(jTextField12.getText());
                if (td>0)
                {
                    jTextArea2.append("Please type in a negative float number for threshold of copy number deletion" 
                                               + "\n" + "\n");
                    jTextField12.setText("");
                    jButton3.setEnabled(true);
                    errorFlag = true;
                }
            }
            catch (NumberFormatException e)
            {
                jTextArea2.append("Please type in a negative float number for threshold of copy number deletion" 
                                               + "\n" + "\n");
                jTextField12.setText("");
                jButton3.setEnabled(true);
                errorFlag = true;
            }
            
            try 
            {
                double np = Integer.parseInt(jTextField13.getText());
             
                if (np<0)
                {
                    jTextArea2.append("Please type in a positive integer number for number of permutation"
                                              + "\n"+ "\n");
                    jTextField13.setText("");
                    jButton3.setEnabled(true); 
                    errorFlag = true;
                }
            }
            catch (NumberFormatException e)
            {
                jTextArea2.append("Please type in a positive integer number for number of permutation"
                                              + "\n"+ "\n");
                jTextField13.setText("");
                jButton3.setEnabled(true); 
                errorFlag = true;
            }
            
            try 
            {
                double tc = Double.parseDouble(jTextField14.getText());
             
                if (tc>1 || tc<0)
                {
                    jTextArea2.append("Please type in a float number between 0 and 1 for correlation coefficient" 
                                              + "\n"+ "\n");
                    jTextField14.setText("");
                    jButton3.setEnabled(true); 
                    errorFlag = true;
                }
            }
            catch (NumberFormatException e)
            {
                jTextArea2.append("Please type in a float number between 0 and 1 for correlation coefficient"
                                              + "\n"+ "\n");
                jTextField14.setText("");
                jButton3.setEnabled(true);
                errorFlag = true;
            }  
            
            if (!errorFlag)
            {     
                mySwingAISAIC = new SwingAISAIC();
                mySwingAISAIC.execute();                 
            }
            
        }        
        
      

}//GEN-LAST:event_jButton3ActionPerformed
   private class SwingAISAIC extends SwingWorker<Void, String>
   {      
       ForkJoinPool bacomForkJoinPool, detectSCAForkJoinPool;
       CorrectNormalContam correctNormalContam;
       DetectSCAs detectSCAs;
              
       public SwingAISAIC()
       {
            saicPara.setTa(Double.parseDouble(jTextField11.getText()));
            saicPara.setTd(Double.parseDouble(jTextField12.getText()));
            saicPara.setIterFlag(jRadioButton6.isSelected());
            saicPara.setNp(Integer.parseInt(jTextField13.getText()));
            saicPara.setTci(Double.parseDouble(jTextField14.getText()));
            saicPara.setQuickSAIC(jRadioButton7.isSelected());
            try{
                saicPara.setGeneRefDir(jTextField8.getText());
            }catch(FileDoesNotExistException e){
                System.out.println("Can not find the specified gene reference file, please check again.");
            }
            saicPara.setIsAISAIC(true);
            if(jComboBox2.getSelectedItem() == "Genome-wide analysis")
                saicPara.setAnalysisMode(2);
            else if(jComboBox2.getSelectedItem() == "Multiple chromosomes analysis")
                saicPara.setAnalysisMode(1);
                        
            try{
                bacomPara.setInputCdfFile(jTextField6.getText());
            }catch (Exception e){
                jTextArea2.append("The speciied CDF file does not exist, please check again." + "\n" + "\n");
            }
            bacomPara.setInputNormalFile(jTextField3.getText());
            bacomPara.setInputTumorFile(jTextField5.getText());
            
            File resultFolder = new File (jTextField4.getText() + File.separator + "results");
            if(!resultFolder.exists()){
                resultFolder.mkdir();
            }
            bacomPara.setResultFolder(resultFolder.getAbsolutePath());
            File loggerFile = new File(bacomPara.getResultFolder() + File.separator + "logFile.txt");
            if (loggerFile != null && loggerFile.exists())
                loggerFile.delete();   
            try{
                Logger.setLogger(loggerFile.getPath());
            }
            catch (IOException e){
                jTextArea2.append("Error creating logger file!" + "\n" + "\n");
            }
            
            try{
                bacomPara.setAnnotationFile(jTextField9.getText());
            }catch (Exception e){
                jTextArea2.append("The speciied annotation file does not exist, please check again." + "\n" + "\n");
            }
            
       }
            
       protected Void doInBackground() throws Exception
       {                                             
            //   Bacom analysis //
            
            bacomPara.setAnalysisMode("1");

            int numSampleConcur = Runtime.getRuntime().availableProcessors();
            if (numSampleConcur > 6)
                numSampleConcur = numSampleConcur -4;
            else if (numSampleConcur <= 4)
                numSampleConcur = 1;
                
            try{
                bacomPara.setNormalSamples();
            }
            catch (FileDoesNotExistException e1){
                publish("The file does not exist, please check again.");
            }
            catch (IOException e2){
                publish("Error reading the file!");
            }
            bacomPara.setInputTumorFile(jTextField5.getText());
            try{
                bacomPara.setTumorSamples();
            }
            catch (FileDoesNotExistException e1){
                publish("The file does not exist, please check again.");
            }
            catch (IOException e2){
                publish("Error reading the file!");
            }
            catch (SampleSizeDoesNotMatchException e3){
                publish("Tumor sample size and normal size sample does not match, please check the input file");
            }

          int j;                    
          long startTime = System.currentTimeMillis();                    
          publish("Total of " + bacomPara.getSampleSize() + " samples" + "\n" + "\n");                    
          publish("Start analyzing using BACOM ..." + "\n" + "\n");    

          bacomForkJoinPool = new ForkJoinPool(); 
          for (j=0; j<bacomPara.getSampleSize()/numSampleConcur; j++)
          {   
              publish("Having processed " + j*numSampleConcur + " samples already." + "\n" + "\n");
              publish("Start analyzing the next " + numSampleConcur + " samples parallelly, this may take couple of minutes... " + "\n" + "\n");  
              Long start = System.currentTimeMillis();
              correctNormalContam = new CorrectNormalContam(bacomPara, numSampleConcur*j, numSampleConcur*(j+1)-1);                    
              bacomForkJoinPool.invoke(correctNormalContam);   
              publish ("The time consumption for analyzing these " + numSampleConcur + " samples is " + (System.currentTimeMillis() - start)/1000 + " seconds" + "\n" + "\n");
          }                  

          int remain = bacomPara.getSampleSize()%numSampleConcur;  
          publish("Having processed " + (bacomPara.getSampleSize()-remain) + " samples already." + "\n" + "\n");
          publish ("Analysing the remaining " + remain + " samples parallelly" + "\n" + "\n");  
          if (remain!=0)
          {                                         
            correctNormalContam = new CorrectNormalContam(bacomPara,bacomPara.getSampleSize()-remain, bacomPara.getSampleSize()-1);                    
            bacomForkJoinPool.invoke(correctNormalContam);
          }

          publish("Done with BACOM analysis !" + "\n" + "\n");                    
          String status = "Total time consumption of analylzing these samples is: "
                  + (System.currentTimeMillis() - startTime)/1000 + " seconds" + "\n" + "\n";                
          publish(status);                    
          publish ("The normal tissue contamination for these samples are:" + "\n" + "\n");

          for (int k=0; k<bacomPara.getSampleSize();k++)
          {
              status = bacomPara.getSampleIds().get(k) + ": " + bacomPara.getAlpha()[k] + "\n" + "\n";                        
              publish (status);                    
          }     

          if (bacomPara.getGeneInterested() != null){
            publish(GeneDeletionInfo.getInstance().getNumHomoDeletion() + " out of " + bacomPara.getSampleSize() + " samples have Homo-deletion."  + "\n" + "\n");                  
            publish(GeneDeletionInfo.getInstance().getNumHemiDeletion() + " out of " + bacomPara.getSampleSize() + " samples have Hemi-deletion."  + "\n" + "\n");
            GeneDeletionInfo.getInstance().reset();
          }
          saicPara.setSampleID(bacomPara.getSampleIds());

          bacomForkJoinPool = null;
          correctNormalContam = null;

         if (bacomPara.getSampleSize()<5){
             publish ("Too few samples, please try with more samples");
             return null;
         }

         // Convert BACOM results into SAIC inputS
         if (!mySwingAISAIC.isCancelled()){                     
            saicPara.setBACOMResultDir(bacomPara.getResultFolder() + File.separator + "BACOMResults" + File.separator);
            
            File resultFolder = new File (bacomPara.getResultFolder() + File.separator + "SAICInput");
            if(!resultFolder.exists()){
                resultFolder.mkdir();
            }
            saicPara.setInfileDir(resultFolder.getAbsolutePath()+ File.separator);
            
            resultFolder = new File (bacomPara.getResultFolder() + File.separator + "SAICResults");
            if(!resultFolder.exists()){
                resultFolder.mkdir();
            }
            saicPara.setOutfileDir(resultFolder.getAbsolutePath() + File.separator);

            publish ("Converting BACOM results to SAIC input..." + "\n" + "\n");
            DataConversion convertForSAIC = new DataConversion(bacomPara.getAlpha(), bacomPara.getSampleIds(), saicPara.getBACOMResultDir(), saicPara.getInfileDir());                         

             try{
                convertForSAIC.transform();
             }
             catch(IOException e)
             {
                 publish("Can not convert BACOM results to SAIC input because no BACOM results available." + "\n" + "\n");
                 return null;
             }  

         // Saic analysis

             publish ("Detecting Significant Copy number Aberrations..." + "\n" + "\n");       

             GeneSet.readGeneInfo (saicPara.getGeneRefDir());             

               if (saicPara.getAnalysisMode() == 2)
               {
                    String infiles[] = new String[1];
                    String outfiles[] = new String[1];               

                    infiles[0] = saicPara.getInfileDir()+ "GenomeWide";
                    outfiles[0] = saicPara.getOutfileDir()+ "ResultGenomeWide";                
                    publish ("Detecting SCAs in the whole genome..." + "\n" + "\n");                
                    long StartTime = System.currentTimeMillis();
                    DetectSCAs myDetect = new DetectSCAs(saicPara, infiles, outfiles);                
                    ForkJoinPool DetectForkJoinPool = new ForkJoinPool();                                       
                    DetectForkJoinPool.invoke(myDetect);                
                    long TaskTime = (System.currentTimeMillis() - StartTime)/1000;                
                    publish("The analysis time for the whole genome analysis is " + TaskTime + " seconds" + "\n" + "\n");                
                    myDetect = null;                
                    DetectForkJoinPool = null;
               }

               else if (saicPara.getAnalysisMode() == 1)
               {     
                   String infiles[] = new String[1];                
                   String outfiles[] = new String[1];

                   publish ("Start SCAs detection using SAIC ..." + "\n" + "\n");                               
                   for (int chr =22; chr>0; chr=chr-1) 
                   {
                       infiles[0] = saicPara.getInfileDir()+ "Chr" + chr;
                       outfiles[0] = saicPara.getOutfileDir()+ "ResultChr" + chr;

                       publish ("Detecting SCAs in chromosome " + chr + "..." + "\n" + "\n");                                                     
                       detectSCAs = new DetectSCAs(saicPara, infiles, outfiles);  

                       detectSCAForkJoinPool = new ForkJoinPool();                    
                       startTime = System.currentTimeMillis();                    
                       detectSCAForkJoinPool.invoke(detectSCAs);                    
                       publish("The analyzing time for this group of chromosomes is " + (System.currentTimeMillis() - startTime)/1000 + " seconds"+ "\n" + "\n");                                      
                       detectSCAs = null;                    
                       detectSCAForkJoinPool = null;           
                    }
                }               
                // Plot SAIC result figures

                double[] cn;
                String[] chrID;
                int[] loc;
                String fileName;
                double[] meanVal;
                boolean[] isSignificant;

                final String DATA_PATH = saicPara.getOutfileDir();
                final String AMP_FILE_SUFFIX = "_ampAvgCNA";
                final String DEL_FILE_SUFFIX = "_delAvgCNA";

                File figureDir = new File(FIG_PATH);

                // if the directory does not exist, create it
                if (!figureDir.exists()) {
                    figureDir.mkdir();  
                }
                if ( saicPara.getAnalysisMode() == 2){
                    final String FILE_PREFIX_GENOME = "ResultGenomeWide";
                    String ampFile = DATA_PATH + FILE_PREFIX_GENOME +  AMP_FILE_SUFFIX;
                    String delFile = DATA_PATH + FILE_PREFIX_GENOME + DEL_FILE_SUFFIX;
                    String figureFileName = FIG_PATH + "AISAIC_genome.png";
                    String genome = "genome";
                    File af = new File(ampFile);
                    File df = new File(delFile);
                    if(af.exists() || df.exists()) {
                        AisaicPlot p = createAisaicPlotObjectFromDataFiles(genome,
                                ampFile, delFile);
                        p.plot();
                        p.saveChartAsPNG(figureFileName);
                    }
                } else if(saicPara.getAnalysisMode() == 1){
                    String[] chrArray = {"1", "2", "3", "4", "5", "6", "7", "8", 
                        "9", "10", "11", "12", "13", "14", "15", "16", "17", "18", 
                        "19", "20", "21", "22"};
                    for (String chr: chrArray) {
                        final String FILE_PREFIX_CHR = "ResultChr";
                        String ampFile = DATA_PATH + FILE_PREFIX_CHR + chr + AMP_FILE_SUFFIX;
                        String delFile = DATA_PATH + FILE_PREFIX_CHR + chr + DEL_FILE_SUFFIX;
                        String figureFileName = FIG_PATH + "AISAIC_chr_" + chr + ".png";
                        File af = new File(ampFile);
                        File df = new File(delFile);
                        if(af.exists() || df.exists()) {
                            AisaicPlot p = createAisaicPlotObjectFromDataFiles(chr,
                                    ampFile, delFile);
                            p.plot();
                            p.saveChartAsPNG(figureFileName);
                        }
                    }
                }

                saicPara = null;
                bacomPara = null;
                publish ("Done with the analysis!" + "\n" + "\n");
         }
         return null;
       }
       
        @Override
        protected void process(List<String> PrintOuts)
        {
            for(String PrintOut: PrintOuts )
                jTextArea2.append(PrintOut);          
        }    
        
        @Override
        protected void done(){
                        
            jButton3.setEnabled(true);
            jButton9.setEnabled(false);
            
             try{
                mySwingAISAIC.get();
             }
             catch (CancellationException e1) {
                 if (bacomForkJoinPool != null)
                    bacomForkJoinPool.shutdownNow();
                 if (detectSCAForkJoinPool != null)
                    detectSCAForkJoinPool.shutdownNow();
                 return;
             }
             catch(InterruptedException e2){
                 if (bacomForkJoinPool != null)
                    bacomForkJoinPool.shutdownNow();
                 if (detectSCAForkJoinPool != null)
                    detectSCAForkJoinPool.shutdownNow();
                  return;
             }
             catch(ExecutionException e3){
                 if (bacomForkJoinPool != null)
                    bacomForkJoinPool.shutdownNow();
                 if (detectSCAForkJoinPool != null)
                    detectSCAForkJoinPool.shutdownNow();
                  return;
             }
        }
   }
    
    
    private class SwingBACOM extends SwingWorker<Void, String> 
    {       
        CorrectNormalContam correctNormalContam;        
        ForkJoinPool bacomForkJoinPool;  
        
        public SwingBACOM(){
            bacomPara.setInputNormalFile(jTextField3.getText());
            bacomPara.setInputTumorFile(jTextField5.getText());            
            File resultFolder = new File (jTextField4.getText() + File.separator + "results");
            if(!resultFolder.exists()){
                resultFolder.mkdir();
            }
            bacomPara.setResultFolder(resultFolder.getAbsolutePath());
            File loggerFile = new File(bacomPara.getResultFolder() + File.separator + "logFile.txt");
            if (loggerFile != null && loggerFile.exists())
                loggerFile.delete();   
            try{
                Logger.setLogger(loggerFile.getPath());
            }
            catch (IOException e){
                jTextArea2.append("Error creating logger file!" + "\n" + "\n");
            }
            
            try{
                bacomPara.setInputCdfFile(jTextField6.getText());
            }catch (Exception e){
                jTextArea2.append("The specified CDF file does not exist, please check again." + "\n" + "\n");
            }
            try{                
                bacomPara.setAnnotationFile(jTextField9.getText());
            }catch (Exception e){
                jTextArea2.append("The specified annotation file does not exist, please check again." + "\n" + "\n");
            }
            
        }        
        
        @Override
        protected Void doInBackground() throws Exception
        {           
            Logger.logging("Start BACOM analysis...");

            // start BACOM analysis 
                     
            long startTime;   
            if (jComboBox1.getSelectedItem() =="Single sample analysis")
            {
                bacomPara.setAnalysisMode("0");
                Logger.logging("User chosed single sample analysis");
                publish("Start estimating the normal tissue contamination fraction in this tumor sample using BACOM ..." + "\n" + "\n");                 

                try{
                bacomPara.setNormalSamples();
                }
                catch (FileDoesNotExistException e1){
                    publish("The file does not exist, please check again.");
                }
                catch (IOException e2){
                    publish("Error reading the file!");
                }
                try{
                    bacomPara.setTumorSamples();
                }
                catch (FileDoesNotExistException e1){
                    publish("The file does not exist, please check again.");
                }
                catch (IOException e2){
                    publish("Error reading the file!");
                }
                catch (SampleSizeDoesNotMatchException e3){
                    publish("Tumor sample size and normal size sample does not match, please check the input file");
                } 
                 
                correctNormalContam = new CorrectNormalContam(bacomPara, 0, 0);                
                bacomForkJoinPool = new ForkJoinPool();                
                startTime = System.currentTimeMillis();
                bacomForkJoinPool.invoke(correctNormalContam);                 

                publish("Done with the analysis." + "\n" + "\n");                
                publish("Normal Tissue Contamination Fraction for this tumor sample is " 
                                        + bacomPara.getAlpha()[0] + "\n" + "\n");                 
                publish("Total time consumption of analyzing this sample is: "
                          + (System.currentTimeMillis() - startTime)/1000 + " seconds" + "\n" + "\n"); 
                
                if (bacomPara.getGeneInterested() != null){
                    if (GeneDeletionInfo.getInstance().getNumHemiDeletion()!=0)
                        publish("The interested gene has Hemi-Deletion in this sample" + "\n" + "\n");
                    else if (GeneDeletionInfo.getInstance().getNumHomoDeletion()!=0)
                        publish("The interested gene has Homo-Deletion in this sample" + "\n" + "\n");
                    else
                        publish("The interested gene has no deletion in this sample" + "\n" + "\n");                
                    GeneDeletionInfo.getInstance().reset();
                }            
            }
            else 
            {   
                Logger.logging("User chosed multiple samples analysis "); 
                bacomPara.setAnalysisMode("1");
                           
                int numSampleConcur = Runtime.getRuntime().availableProcessors();
                if (numSampleConcur > 4)
                    numSampleConcur = numSampleConcur -2;
                else if (numSampleConcur <= 2)
                    numSampleConcur = 1;

                try{
                    bacomPara.setNormalSamples();
                }
                catch (FileDoesNotExistException e1){
                    publish("The file does not exist, please check again.");
                }
                catch (IOException e2){
                    publish("Error reading the file!");
                }
                try{
                    bacomPara.setTumorSamples();
                }
                catch (FileDoesNotExistException e1){
                    publish("The file does not exist, please check again.");
                }
                catch (IOException e2){
                    publish("Error reading the file!");
                }
                catch (SampleSizeDoesNotMatchException e3){
                    publish("Tumor sample size and normal size sample does not match, please check the input file");
                }

                startTime = System.currentTimeMillis();                    
                publish("Total of " + bacomPara.getSampleSize() + " samples" + "\n" + "\n");                    
                publish("Start estimating the normal tissue contamination fraction for these tumor samples using BACOM ..." + "\n" + "\n");

                if (bacomPara.getSampleSize() < numSampleConcur)
                    numSampleConcur = bacomPara.getSampleSize();
                
                bacomForkJoinPool = new ForkJoinPool(); 
                for (int j=0; j<bacomPara.getSampleSize()/numSampleConcur; j++)
                {
                    publish("Having processed " + j*numSampleConcur + " samples already." + "\n" + "\n");
                    publish("Start analyzing the next " + numSampleConcur + " samples parallelly, this may take couple of minutes... " + "\n" + "\n");                                              
                    correctNormalContam = new CorrectNormalContam(bacomPara, numSampleConcur*j,numSampleConcur*(j+1)-1);               
                    Long begin = System.currentTimeMillis();
                    bacomForkJoinPool.invoke(correctNormalContam);
                    publish ("It takes " + (System.currentTimeMillis()-begin)/1000 + " seconds to finish analyzing these " + numSampleConcur + "samples." + "\n" + "\n");
                }        

                int remain = bacomPara.getSampleSize()%numSampleConcur; 
                publish("Having processed " + (bacomPara.getSampleSize()-remain) + " samples already." + "\n" + "\n");
                publish ("Analysing the remaining " + remain + " samples parallelly" + "\n" + "\n");                                                          
                correctNormalContam = new CorrectNormalContam(bacomPara,bacomPara.getSampleSize()-remain, bacomPara.getSampleSize()-1);                    
                bacomForkJoinPool.invoke(correctNormalContam);  

                publish ("Done with analyzing all of these samples. " + "\n" + "\n");
                publish("Total time consumption of analylzing these samples is: "
                      + (System.currentTimeMillis() - startTime)/1000 + " seconds" + "\n" + "\n");  

                for (int k=0; k<bacomPara.getSampleSize();k++)                 
                    publish ("The normal tissue contamination for sample " + bacomPara.getSampleIds().get(k) + " is: " + bacomPara.getAlpha()[k] + "\n"+ "\n");                    

                if (bacomPara.getGeneInterested() != null){
                    publish(GeneDeletionInfo.getInstance().getNumHomoDeletion() + " out of " + bacomPara.getSampleSize() + " samples have Homo-deletion."  + "\n" + "\n");                               
                    publish(GeneDeletionInfo.getInstance().getNumHemiDeletion() + " out of " + bacomPara.getSampleSize() + " samples have Hemi-deletion."  + "\n" + "\n");                  
                    GeneDeletionInfo.getInstance().reset();  
                }                                                    
                bacomForkJoinPool = null;
                correctNormalContam = null;
                bacomPara = null;
            }           
            return null;            
        }
        
        @Override
        protected void process(List<String> PrintOuts) 
        {
            for(String PrintOut: PrintOuts )
            jTextArea2.append(PrintOut);        
        
        }           
                
        @Override
        protected void done(){
            
            jButton3.setEnabled(true);
            jButton9.setEnabled(false);
            
             try{
                mySwingBACOM.get();
             }
             catch (CancellationException e1) {
                 if (bacomForkJoinPool != null){
                    bacomForkJoinPool.shutdownNow();
                 }
                 return;
             }
             catch(InterruptedException e2){
                 if (bacomForkJoinPool != null){
                    bacomForkJoinPool.shutdownNow();
                 }
                  return;
             }
             catch(ExecutionException e3){
                 if (bacomForkJoinPool != null){
                     bacomForkJoinPool.shutdownNow();
                 }  
                  return;
             }
        }
    
    }
    
    private class SwingSCAs extends SwingWorker<Void, String>
    {
       DetectSCAs detectSCAs;
       ForkJoinPool detectSCAForkJoinPool;
               
       public SwingSCAs()
       {
            saicPara.setTa(Double.parseDouble(jTextField11.getText()));
            saicPara.setTd(Double.parseDouble(jTextField12.getText()));
            saicPara.setIterFlag (jRadioButton6.isSelected());
            saicPara.setNp(Integer.parseInt(jTextField13.getText()));
            saicPara.setTci(Double.parseDouble(jTextField14.getText()));
            saicPara.setQuickSAIC(jRadioButton7.isSelected());
            try{
                saicPara.setGeneRefDir(jTextField8.getText());
            }catch (FileDoesNotExistException e){
                System.out.println("Can not find the specified gene reference file, please check again.");
            }
            saicPara.setIsAISAIC(false);
            saicPara.setSampleID(null);
            saicPara.setInfileDir(jTextField1.getText());            
            File resultDir = new File(jTextField2.getText() + File.separator + "results");
            if (!resultDir.exists())
                resultDir.mkdir();
            File saicResult = new File(resultDir.getAbsolutePath() + File.separator + "SAICResults");
            if(!saicResult.exists())
                saicResult.mkdir();                        
            saicPara.setOutfileDir(saicResult.getAbsolutePath() + File.separator);
            File loggerFile = new File(jTextField2.getText() + File.separator + "results" + File.separator + "logFile.txt");
            if (loggerFile != null && loggerFile.exists())
                loggerFile.delete();   
            try{
                Logger.setLogger(loggerFile.getPath());
            }
            catch (IOException e){
                jTextArea2.append("Error creating logger file!" + "\n" + "\n");
            }
            if(jComboBox2.getSelectedItem() == "Single chromosome analysis")
                saicPara.setAnalysisMode(0);
            else if(jComboBox2.getSelectedItem() == "Multiple chromosomes analysis")
                saicPara.setAnalysisMode(1);
            else if(jComboBox2.getSelectedItem() == "Genome-wide analysis")
                saicPara.setAnalysisMode(2);
            
       }
  
        protected Void doInBackground()
        {             
            String status;
            long StartTime, TaskTime, BeginTime, TotalTime;   
            
            GeneSet.readGeneInfo(saicPara.getGeneRefDir());      

            if (saicPara.getAnalysisMode() == 0|| saicPara.getAnalysisMode() == 2)
            {
                String infiles[] = new String[1];
                String outfiles[] = new String[1];             
            
                infiles[0] = jTextField1.getText();               
                
                if (saicPara.getAnalysisMode() == 2){
                  publish ("Detecting SCAs in the whole genome..." + "\n" + "\n");
                  outfiles[0] = saicPara.getOutfileDir() + "ResultGenomeWide";
                }
                else if (saicPara.getAnalysisMode() == 0){
                    publish ("Detecting SCAs in this chromosome..." + "\n" + "\n");
                    outfiles[0] = saicPara.getOutfileDir() + "Result";
                }
                
                StartTime = System.currentTimeMillis();
                detectSCAs = new DetectSCAs(saicPara, infiles, outfiles);                
                detectSCAForkJoinPool = new ForkJoinPool();                                       
                detectSCAForkJoinPool.invoke(detectSCAs);                
                TaskTime = (System.currentTimeMillis() - StartTime)/1000;                
                publish("The analysis time for this chromosome is " + TaskTime + " seconds" + "\n" + "\n");                
            } 
            else if (saicPara.getAnalysisMode() == 1)
            {                
                String infiles[] = new String[1];
                String outfiles[] = new String[1];
                BeginTime = System.currentTimeMillis();
                File file = null;     
                saicPara.setInfileDir(jTextField1.getText() + File.separator );
                for (int chr =22; chr>0; chr--) 
                {
                    infiles[0] = saicPara.getInfileDir() + "Chr" + chr;
                    file = new File(infiles[0]);
                    if (!file.exists())
                        jTextArea2.append("Can not find the file Chr" + chr + ", please check again." + "\n" + "\n");                    
                    outfiles[0] = saicPara.getOutfileDir() + "ResultChr" + chr;
                    publish ("Detecting SCAs in chromosome " + chr + "..." + "\n" + "\n");                                                          
                    detectSCAs = new DetectSCAs(saicPara, infiles, outfiles);                                   
                    detectSCAForkJoinPool = new ForkJoinPool();                    
                    StartTime = System.currentTimeMillis();                    
                    detectSCAForkJoinPool.invoke(detectSCAs);                                                      
                    publish("The analyzing time for this group of chromosomes is " + (System.currentTimeMillis() - StartTime)/1000 + " seconds"+ "\n" + "\n");                    
                    
                }                
                publish("The total time for analyzing 22 chromosomes is " + (System.currentTimeMillis() - BeginTime)/60000 + " minutes" + "\n" + "\n");
            } 
                           
             // Plot SAIC result figures
            
            publish("Finish detecting SCAs in the chromosomes/genome. " + "\n" + "\n");
            publish("Start plotting the results..." + "\n" + "\n");

            double[] cn;
            String[] chrID;
            int[] loc;
            String fileName;
            double[] meanVal;
            boolean[] isSignificant;

            final String DATA_PATH = saicPara.getOutfileDir();
            
            
            final String AMP_FILE_SUFFIX = "_ampAvgCNA";
            final String DEL_FILE_SUFFIX = "_delAvgCNA";         
            
            File figureDir = new File(FIG_PATH);

            // if the directory does not exist, create it
            if (!figureDir.exists()) {
                figureDir.mkdir();  
            }
           
            if (saicPara.getAnalysisMode() ==0 ){
                final String FILE_PREFIX = "Result";
                String ampFile = DATA_PATH + FILE_PREFIX +  AMP_FILE_SUFFIX;
                String delFile = DATA_PATH + FILE_PREFIX + DEL_FILE_SUFFIX;
                String figureFileName = FIG_PATH + "AISAIC_singleChr.png";
                String chr0 = "";
                File af = new File(ampFile);
                File df = new File(delFile);
                if(af.exists() || df.exists()) {
                    AisaicPlot p = createAisaicPlotObjectFromDataFiles(chr0,
                            ampFile, delFile);
                    p.plot();
                    p.saveChartAsPNG(figureFileName);       
                }
            }
             else if(saicPara.getAnalysisMode() == 1){
                String[] chrArray = {"1", "2", "3", "4", "5", "6", "7", "8", 
                "9", "10", "11", "12", "13", "14", "15", "16", "17", "18", 
                "19", "20", "21", "22"};
                for (String chr: chrArray) {
                    final String FILE_PREFIX_CHR = "ResultChr";
                    String ampFile = DATA_PATH + FILE_PREFIX_CHR + chr + AMP_FILE_SUFFIX;
                    String delFile = DATA_PATH + FILE_PREFIX_CHR + chr + DEL_FILE_SUFFIX;
                    String figureFileName = FIG_PATH + "AISAIC_chr_" + chr + ".png";
                    File af = new File(ampFile);
                    File df = new File(delFile);
                    if(af.exists() || df.exists()) {
                        AisaicPlot p = createAisaicPlotObjectFromDataFiles(chr,
                                ampFile, delFile);
                        p.plot();
                        p.saveChartAsPNG(figureFileName);
                    }
                }
            }
            else if ( saicPara.getAnalysisMode() == 2){
                final String FILE_PREFIX_GENOME = "ResultGenomeWide";
                String ampFile = DATA_PATH + FILE_PREFIX_GENOME +  AMP_FILE_SUFFIX;
                String delFile = DATA_PATH + FILE_PREFIX_GENOME + DEL_FILE_SUFFIX;
                String figureFileName = FIG_PATH + "AISAIC_genome.png";
                String genome = "genome";
                File af = new File(ampFile);
                File df = new File(delFile);
                if(af.exists() || df.exists()) {
                    AisaicPlot p = createAisaicPlotObjectFromDataFiles(genome,
                            ampFile, delFile);
                    p.plot();
                    p.saveChartAsPNG(figureFileName);
                }
            }
            
           

            publish ("Done with the analysis" + "\n" + "\n");
            
            detectSCAs = null;
            detectSCAForkJoinPool = null;            
            saicPara = null;
            return null;

        }
        
        protected void process(List<String> PrintOuts)
        {
            for(String PrintOut: PrintOuts )
            jTextArea2.append(PrintOut);            
        
        }
    
         @Override
        protected void done(){
            
            jButton3.setEnabled(true);
            jButton9.setEnabled(false);
            
             try{
                mySwingSCAs.get();
             }
             catch (CancellationException e1) {
                 if (detectSCAForkJoinPool != null){
                    detectSCAForkJoinPool.shutdownNow();
                 }
                 return;
             }
             catch(InterruptedException e2){
                 if (detectSCAForkJoinPool != null){
                    detectSCAForkJoinPool.shutdownNow();
                 }
                  return;
             }
             catch(ExecutionException e3){
                 if (detectSCAForkJoinPool != null){
                    detectSCAForkJoinPool.shutdownNow();
                 }
                  return;
             }
        }
    
    }
    private void jTextField3ActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_jTextField3ActionPerformed
        // TODO add your handling code here:
    }//GEN-LAST:event_jTextField3ActionPerformed

    private void jTextField4ActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_jTextField4ActionPerformed
        // TODO add your handling code here:
    }//GEN-LAST:event_jTextField4ActionPerformed

    private void jButton4ActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_jButton4ActionPerformed
        // TODO add your handling code here:

        
        JFileChooser jFileChooser = new JFileChooser();
        if (jComboBox1.getSelectedItem() == "Single sample analysis")
        {
            FileFilter fileFilter = new FileNameExtensionFilter("CEL File", "CEL");
            jFileChooser.setFileFilter(fileFilter);
        }
        
        jFileChooser.setFileSelectionMode(JFileChooser.FILES_ONLY);

        jFileChooser.setCurrentDirectory(currentDir);
        
        int returnVal = jFileChooser.showOpenDialog(getContentPane());
        
        if (returnVal == jFileChooser.APPROVE_OPTION)
        {
            File selectedFile = jFileChooser.getSelectedFile();
            currentDir = jFileChooser.getCurrentDirectory();
            jTextField5.setText(selectedFile.getPath());
        }
        else
          jTextArea2.append("File access cancelled by user." + "\n");

        
    }//GEN-LAST:event_jButton4ActionPerformed

    private void jButton5ActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_jButton5ActionPerformed
        // TODO add your handling code here:
       
         JFileChooser jFileChooser = new JFileChooser();
        
        jFileChooser.setFileSelectionMode(JFileChooser.DIRECTORIES_ONLY);

        jFileChooser.setCurrentDirectory(currentDir);
        
        int returnVal = jFileChooser.showOpenDialog(getContentPane());
        
        if (returnVal == jFileChooser.APPROVE_OPTION)
        {
            File selectedFile = jFileChooser.getSelectedFile();
            currentDir = jFileChooser.getCurrentDirectory();
            jTextField4.setText(selectedFile.getPath());
        }
        else
          jTextArea2.append("File access cancelled by user." + "\n");

    }//GEN-LAST:event_jButton5ActionPerformed

    private void jRadioButton1ActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_jRadioButton1ActionPerformed

        bacomOnly = jRadioButton1.isSelected();
        
        if (bacomOnly)
        {
            saicOnly = false;
            bacomAndsaic = false;
            jRadioButton2.setSelected(false);
            jRadioButton4.setSelected(false);
            
         // Disable SAIC components            

            jRadioButton6.setEnabled(false);
            jRadioButton7.setEnabled(false);
            jTextField1.setEnabled(false);
            jTextField2.setEnabled(false);
            jButton1.setEnabled(false);
            jButton2.setEnabled(false);
            jTextField11.setEditable(false);
            jTextField12.setEditable(false);
            jTextField13.setEditable(false);
            jTextField14.setEditable(false);
            jTextField8.setEnabled(false);
            jButton8.setEnabled(false);
            jComboBox2.setEnabled(false);
     
         //Enable BACOM compnents   
            
            jButton4.setEnabled(true);
            jButton5.setEnabled(true);
            jButton6.setEnabled(true);
            jButton7.setEnabled(true);
            jButton10.setEnabled(true);
            jTextField3.setEnabled(true);
            jTextField4.setEnabled(true);
            jTextField5.setEnabled(true);
            jTextField6.setEnabled(true);
            jComboBox1.setEnabled(true);
            jTextField7.setEditable(true);
            jTextField9.setEnabled(true);
            
        }

        // TODO add your handling code here:
    }//GEN-LAST:event_jRadioButton1ActionPerformed

    private void jRadioButton2ActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_jRadioButton2ActionPerformed
        // TODO add your handling code here:
        saicOnly = jRadioButton2.isSelected();
        if (saicOnly)
        {
            bacomOnly = false;
            bacomAndsaic = false;
            jRadioButton1.setSelected(false);
            jRadioButton4.setSelected(false);
            
        //Enable SAIC components   
                        
            jRadioButton6.setEnabled(true);
            jRadioButton7.setEnabled(true);
            jTextField1.setEnabled(true);
            jTextField2.setEnabled(true);
            jButton1.setEnabled(true);
            jButton2.setEnabled(true);
            jTextField11.setEditable(true);
            jTextField12.setEditable(true);
            jTextField13.setEditable(true);
            jTextField14.setEditable(true);
            jTextField8.setEnabled(true);
            jButton8.setEnabled(true);
            jComboBox2.setModel(new javax.swing.DefaultComboBoxModel(new String[] { "Single chromosome analysis", "Multiple chromosomes analysis", "Genome-wide analysis" }));
            jComboBox2.setEnabled(true);
        
        // Disable BACOM components    
            
            jButton4.setEnabled(false);
            jButton5.setEnabled(false);
            jButton6.setEnabled(false);
            jButton7.setEnabled(false);
            jButton10.setEnabled(false);
            jTextField3.setEnabled(false);
            jTextField4.setEnabled(false);
            jTextField5.setEnabled(false);
            jTextField6.setEnabled(false);
            jComboBox1.setEnabled(false);
            jTextField7.setEditable(false);
            jTextField9.setEnabled(false);
       
        }
    }//GEN-LAST:event_jRadioButton2ActionPerformed

    private void jRadioButton4ActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_jRadioButton4ActionPerformed
        // TODO add your handling code here:
        bacomAndsaic = jRadioButton4.isSelected();
        if (bacomAndsaic)
        {
            jRadioButton1.setSelected(false);
            jRadioButton2.setSelected(false);
            bacomOnly = false;
            saicOnly = false;
            
       //Enable SAIC components     
            
            jRadioButton6.setEnabled(true);
            jRadioButton7.setEnabled(true);
            jTextField1.setEnabled(false);
            jTextField2.setEnabled(false);
            jButton1.setEnabled(false);
            jButton2.setEnabled(false);
            jTextField11.setEditable(true);
            jTextField12.setEditable(true);
            jTextField13.setEditable(true);
            jTextField14.setEditable(true);
            jTextField8.setEnabled(true);
            jButton8.setEnabled(true);
            jComboBox2.setEnabled(true);            
            jComboBox2.setModel(new javax.swing.DefaultComboBoxModel(new String[] {"Multiple chromosomes analysis", "Genome-wide analysis" }));
            jComboBox2.setSelectedItem("Multiple chromosomes analysis");
            
       //Enable BACOM components
            
            jButton4.setEnabled(true);
            jButton5.setEnabled(true);
            jButton6.setEnabled(true);
            jButton7.setEnabled(true);
            jButton10.setEnabled(true);
            jTextField3.setEnabled(true);
            jTextField4.setEnabled(true);
            jTextField5.setEnabled(true);
            jTextField6.setEnabled(true);   
            jComboBox1.setEnabled(true);
            jTextField7.setEditable(true);
            jTextField9.setEnabled(true);
            jComboBox1.setSelectedItem("Multiple samples analysis");
        }
    }//GEN-LAST:event_jRadioButton4ActionPerformed

    private void jTextField5ActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_jTextField5ActionPerformed
        // TODO add your handling code here:
    }//GEN-LAST:event_jTextField5ActionPerformed

    private void jButton6ActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_jButton6ActionPerformed
        // TODO add your handling code here:

        JFileChooser jFileChooser = new JFileChooser();
        if (jComboBox1.getSelectedItem() == "Single sample analysis")
        {
            FileFilter fileFilter = new FileNameExtensionFilter("CEL File", "CEL");
            jFileChooser.setFileFilter(fileFilter);
        }
        
        jFileChooser.setFileSelectionMode(JFileChooser.FILES_ONLY);

        jFileChooser.setCurrentDirectory(null);
        
        int returnVal = jFileChooser.showOpenDialog(getContentPane());
        
        if (returnVal == jFileChooser.APPROVE_OPTION)
        {
            File selectedFile = jFileChooser.getSelectedFile();
            currentDir = jFileChooser.getCurrentDirectory();
            jTextField3.setText(selectedFile.getPath());
        }
        else
          jTextArea2.append("File access cancelled by user." + "\n");

        
        
        
    }//GEN-LAST:event_jButton6ActionPerformed

    private void jTextField6ActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_jTextField6ActionPerformed
        // TODO add your handling code here:
    }//GEN-LAST:event_jTextField6ActionPerformed

    private void jButton7ActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_jButton7ActionPerformed
        // TODO add your handling code here:

        JFileChooser jFileChooser = new JFileChooser();
        
        FileFilter fileFilter = new FileNameExtensionFilter("CDF File", "CDF");
        
        jFileChooser.setFileFilter(fileFilter);
        
        jFileChooser.setFileSelectionMode(JFileChooser.FILES_ONLY);

        jFileChooser.setCurrentDirectory(currentDir);
        
        int returnVal = jFileChooser.showOpenDialog(getContentPane());
        
        if (returnVal == jFileChooser.APPROVE_OPTION)
        {
            File selectedFile = jFileChooser.getSelectedFile();
            currentDir = jFileChooser.getCurrentDirectory();
            jTextField6.setText(selectedFile.getPath());
        }
        else
            jTextArea2.append("File access cancelled by user." + "\n"+ "\n");

    }//GEN-LAST:event_jButton7ActionPerformed

    private void jComboBox1ActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_jComboBox1ActionPerformed
        // TODO add your handling code here:
    }//GEN-LAST:event_jComboBox1ActionPerformed

    private void jTextField7ActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_jTextField7ActionPerformed
        // TODO add your handling code here:
        
        
    }//GEN-LAST:event_jTextField7ActionPerformed

    private void jComboBox2ActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_jComboBox2ActionPerformed
        // TODO add your handling code here:
        String selectedText = String.valueOf(jComboBox2.getSelectedItem());
        switch (selectedText) {
            case "Single chromosome analysis":
                jMenuMultipleChrViz.setEnabled(false);
                jMenuItemSingleChrViz.setEnabled(true);
                jMenuItemGenomeWideViz.setEnabled(false);
                break;
            case "Genome-wide analysis":
                jMenuMultipleChrViz.setEnabled(false);
                jMenuItemSingleChrViz.setEnabled(false);
                jMenuItemGenomeWideViz.setEnabled(true);
                break;
            default:
                jMenuMultipleChrViz.setEnabled(true);
                jMenuItemSingleChrViz.setEnabled(false);
                jMenuItemGenomeWideViz.setEnabled(false);
                break;
        }
    }//GEN-LAST:event_jComboBox2ActionPerformed

    private void jButton8ActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_jButton8ActionPerformed
        // TODO add your handling code here:

        JFileChooser jFileChooser = new JFileChooser();

        jFileChooser.setFileSelectionMode(JFileChooser.FILES_ONLY);

        jFileChooser.setCurrentDirectory(currentDir);

        int returnVal = jFileChooser.showOpenDialog(getContentPane());

        if (returnVal == jFileChooser.APPROVE_OPTION)
        {
            File selectedFile = jFileChooser.getSelectedFile();
            currentDir = jFileChooser.getCurrentDirectory();
            jTextField8.setText(selectedFile.getPath());
        }
        else
        jTextArea2.append("File access cancelled by user." + "\n"+ "\n");
    }//GEN-LAST:event_jButton8ActionPerformed

    private void jTextField8ActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_jTextField8ActionPerformed
        // TODO add your handling code here:
    }//GEN-LAST:event_jTextField8ActionPerformed

    private void jRadioButton7ActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_jRadioButton7ActionPerformed
        // TODO add your handling code here:
    }//GEN-LAST:event_jRadioButton7ActionPerformed

    private void jRadioButton6ActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_jRadioButton6ActionPerformed
        // TODO add your handling code here:
    }//GEN-LAST:event_jRadioButton6ActionPerformed

    private void jTextField14ActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_jTextField14ActionPerformed
        // TODO add your handling code here:
        double tc;
        try
        {
            tc = Double.parseDouble(jTextField14.getText());

            if (tc>1 || tc<0)
            jTextArea2.append("Please type in a float number between 0 and 1" + "\n"+ "\n");
        }
        catch (NumberFormatException e)
        {
            jTextArea2.append("Please type in a float number between 0 and 1" + "\n"+ "\n");
            jTextField14.setText("");
        }
    }//GEN-LAST:event_jTextField14ActionPerformed

    private void jTextField13ActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_jTextField13ActionPerformed
        // TODO add your handling code here:
        try
        {
            double np = Integer.parseInt(jTextField13.getText());

            if (np<0)
            jTextArea2.append("Please type in a positive integer number" + "\n"+ "\n");
        }
        catch (NumberFormatException e)
        {
            jTextArea2.append("Please type in a positive integer number" + "\n"+ "\n");
            jTextField13.setText("");
        }
    }//GEN-LAST:event_jTextField13ActionPerformed

    private void jTextField12ActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_jTextField12ActionPerformed
        // TODO add your handling code here:

        try
        {
            double td = Double.parseDouble(jTextField12.getText());
            if (td>0)
            jTextArea2.append("Please type in a negative float number" + "\n" + "\n");
        }
        catch (NumberFormatException e)
        {
            jTextArea2.append("Please type in a float number" + "\n" + "\n");
            jTextField12.setText("");
        }
    }//GEN-LAST:event_jTextField12ActionPerformed

    private void jTextField11ActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_jTextField11ActionPerformed
        // TODO add your handling code here:

        try
        {
            double  ta = Double.parseDouble(jTextField11.getText());

            if (ta<0)
            jTextArea2.append("Please type in a positive float number" + "\n" + "\n");
        }
        catch (NumberFormatException e)
        {
            jTextArea2.append("Please type in a float number" + "\n");
            jTextField11.setText("");
        }
    }//GEN-LAST:event_jTextField11ActionPerformed

    private void jButton2ActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_jButton2ActionPerformed
  
         JFileChooser jFileChooser = new JFileChooser();        
        if (jComboBox2.getSelectedItem() == "Multiple chromosomes analysis")
        {
            jFileChooser.setFileSelectionMode(JFileChooser.DIRECTORIES_ONLY);
        }
        else
            jFileChooser.setFileSelectionMode(JFileChooser.FILES_ONLY);
        jFileChooser.setCurrentDirectory(null);
        int returnVal = jFileChooser.showOpenDialog(getContentPane());
        if (returnVal == jFileChooser.APPROVE_OPTION)
        {
           File selectedFile = jFileChooser.getSelectedFile();
           currentDir = jFileChooser.getCurrentDirectory();
           jTextField1.setText(selectedFile.getPath());
        }
        else
            jTextArea2.append("File access cancelled by user." + "\n");
        
    }//GEN-LAST:event_jButton2ActionPerformed

    private void jButton1ActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_jButton1ActionPerformed

            JFileChooser jFileChooser = new JFileChooser();
            jFileChooser.setFileSelectionMode(JFileChooser.DIRECTORIES_ONLY);
            jFileChooser.setCurrentDirectory(currentDir);
            int returnVal = jFileChooser.showOpenDialog(getContentPane());
            if (returnVal == jFileChooser.APPROVE_OPTION)
            {                
                File selectedFile = jFileChooser.getSelectedFile();
                currentDir = jFileChooser.getCurrentDirectory();
                jTextField2.setText(selectedFile.getPath());
            }
            else
            jTextArea2.append("File access cancelled by user." + "\n");
        
    }//GEN-LAST:event_jButton1ActionPerformed

    private void jTextField2ActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_jTextField2ActionPerformed

        //  UsrPara.outfile = jTextField1.getText();
    }//GEN-LAST:event_jTextField2ActionPerformed

    private void jTextField1ActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_jTextField1ActionPerformed

        //   UsrPara.infile = jTextField1.getText();
    }//GEN-LAST:event_jTextField1ActionPerformed

    private void jButton9ActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_jButton9ActionPerformed
        // TODO add your handling code here:
        jTextArea2.append("User cancelled the analysis, please allow a little while for the program to terminate all the  executing threads... " + "\n" + "\n");
        jButton3.setEnabled(true);
        jButton9.setEnabled(false);
        if(jRadioButton1.isSelected()){
            mySwingBACOM.cancel(true);
        }
        else if (jRadioButton2.isSelected()){
            mySwingSCAs.cancel(true);
           
        }
        else if (jRadioButton4.isSelected()){
            mySwingAISAIC.cancel(true);
    }           
 
    }//GEN-LAST:event_jButton9ActionPerformed

    private void jTextField9ActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_jTextField9ActionPerformed
        // TODO add your handling code here:
    }//GEN-LAST:event_jTextField9ActionPerformed

    private void jButton10ActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_jButton10ActionPerformed
        // TODO add your handling code here:
        JFileChooser jFileChooser = new JFileChooser();
        
        FileFilter fileFilter = new FileNameExtensionFilter("csv File", "csv");
        
        jFileChooser.setFileFilter(fileFilter);
        
        jFileChooser.setFileSelectionMode(JFileChooser.FILES_ONLY);

        jFileChooser.setCurrentDirectory(currentDir);
        
        int returnVal = jFileChooser.showOpenDialog(getContentPane());
        
        if (returnVal == jFileChooser.APPROVE_OPTION)
        {
            File selectedFile = jFileChooser.getSelectedFile();
            currentDir = jFileChooser.getCurrentDirectory();
            jTextField9.setText(selectedFile.getPath());
        }
        else
            jTextArea2.append("File access cancelled by user." + "\n"+ "\n");
    }//GEN-LAST:event_jButton10ActionPerformed

    private void jMenuItemExitActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_jMenuItemExitActionPerformed
        System.exit(0);   
    }//GEN-LAST:event_jMenuItemExitActionPerformed

    private void jMenuItemChr5ActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_jMenuItemChr5ActionPerformed
        // TODO add your handling code here:
          
        String chr = "5";
        String figureFile = FIG_PATH + "AISAIC_chr_" + chr + ".png";
        System.out.println(figureFile);
        try {
            Desktop.getDesktop().open(new File(figureFile));
        } catch (Exception e) {
            System.err.println(e.getMessage());
        }
    }//GEN-LAST:event_jMenuItemChr5ActionPerformed

    private void jMenuItemAboutActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_jMenuItemAboutActionPerformed
        jDialogAbout.setVisible(true);
    }//GEN-LAST:event_jMenuItemAboutActionPerformed

    private void jButton11ActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_jButton11ActionPerformed
        // TODO add your handling code here:
        jDialogAbout.setVisible(false);
    }//GEN-LAST:event_jButton11ActionPerformed

    private void jMenuItemChr1ActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_jMenuItemChr1ActionPerformed
        // TODO add your handling code here:
        
        String chr = "1";
        String figureFile = FIG_PATH + "AISAIC_chr_" + chr + ".png";
        try {
            Desktop.getDesktop().open(new File(figureFile));
        } catch (Exception e) {
            System.err.println(e.getMessage());
        }
        
    }//GEN-LAST:event_jMenuItemChr1ActionPerformed

    private void jMenuItemChr2ActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_jMenuItemChr2ActionPerformed
        // TODO add your handling code here:
                
        String chr = "2";
        String figureFile = FIG_PATH + "AISAIC_chr_" + chr + ".png";
        try {
            Desktop.getDesktop().open(new File(figureFile));
        } catch (Exception e) {
            System.err.println(e.getMessage());
        }
        
    }//GEN-LAST:event_jMenuItemChr2ActionPerformed

    private void jMenuItemChr3ActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_jMenuItemChr3ActionPerformed
        // TODO add your handling code here:
          
        String chr = "3";
        String figureFile = FIG_PATH + "AISAIC_chr_" + chr + ".png";
        try {
            Desktop.getDesktop().open(new File(figureFile));
        } catch (Exception e) {
            System.err.println(e.getMessage());
        }
    }//GEN-LAST:event_jMenuItemChr3ActionPerformed

    private void jMenuItemChr4ActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_jMenuItemChr4ActionPerformed
        // TODO add your handling code here:
                       
        String chr = "4";
        String figureFile = FIG_PATH + "AISAIC_chr_" + chr + ".png";
        try {
            Desktop.getDesktop().open(new File(figureFile));
        } catch (Exception e) {
            System.err.println(e.getMessage());
        }
    }//GEN-LAST:event_jMenuItemChr4ActionPerformed

    private void jMenuItemChr6ActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_jMenuItemChr6ActionPerformed
        // TODO add your handling code here:
          
        String chr = "6";
        String figureFile = FIG_PATH + "AISAIC_chr_" + chr + ".png";
        try {
            Desktop.getDesktop().open(new File(figureFile));
        } catch (Exception e) {
            System.err.println(e.getMessage());
        }
    }//GEN-LAST:event_jMenuItemChr6ActionPerformed

    private void jMenuItemChr7ActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_jMenuItemChr7ActionPerformed
        // TODO add your handling code here:
          
        String chr = "7";
        String figureFile = FIG_PATH + "AISAIC_chr_" + chr + ".png";
        try {
            Desktop.getDesktop().open(new File(figureFile));
        } catch (Exception e) {
            System.err.println(e.getMessage());
        }
    }//GEN-LAST:event_jMenuItemChr7ActionPerformed

    private void jMenuItemChr8ActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_jMenuItemChr8ActionPerformed
        // TODO add your handling code here:
          
        String chr = "8";
        String figureFile = FIG_PATH + "AISAIC_chr_" + chr + ".png";
        try {
            Desktop.getDesktop().open(new File(figureFile));
        } catch (Exception e) {
            System.err.println(e.getMessage());
        }
    }//GEN-LAST:event_jMenuItemChr8ActionPerformed

    private void jMenuItemChr9ActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_jMenuItemChr9ActionPerformed
        // TODO add your handling code here:
          
        String chr = "9";
        String figureFile = FIG_PATH + "AISAIC_chr_" + chr + ".png";
        try {
            Desktop.getDesktop().open(new File(figureFile));
        } catch (Exception e) {
            System.err.println(e.getMessage());
        }
    }//GEN-LAST:event_jMenuItemChr9ActionPerformed

    private void jMenuItemChr10ActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_jMenuItemChr10ActionPerformed
        // TODO add your handling code here:
          
        String chr = "10";
        String figureFile = FIG_PATH + "AISAIC_chr_" + chr + ".png";
        try {
            Desktop.getDesktop().open(new File(figureFile));
        } catch (Exception e) {
            System.err.println(e.getMessage());
        }
    }//GEN-LAST:event_jMenuItemChr10ActionPerformed

    private void jMenuItemChr11ActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_jMenuItemChr11ActionPerformed
        // TODO add your handling code here:
          
        String chr = "11";
        String figureFile = FIG_PATH + "AISAIC_chr_" + chr + ".png";
        try {
            Desktop.getDesktop().open(new File(figureFile));
        } catch (Exception e) {
            System.err.println(e.getMessage());
        }
    }//GEN-LAST:event_jMenuItemChr11ActionPerformed

    private void jMenuItemChr12ActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_jMenuItemChr12ActionPerformed
        // TODO add your handling code here:
          
        String chr = "12";
        String figureFile = FIG_PATH + "AISAIC_chr_" + chr + ".png";
        try {
            Desktop.getDesktop().open(new File(figureFile));
        } catch (Exception e) {
            System.err.println(e.getMessage());
        }
    }//GEN-LAST:event_jMenuItemChr12ActionPerformed

    private void jMenuItemChr13ActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_jMenuItemChr13ActionPerformed
        // TODO add your handling code here:
        String chr = "13";
        String figureFile = FIG_PATH + "AISAIC_chr_" + chr + ".png";
        try {
            Desktop.getDesktop().open(new File(figureFile));
        } catch (Exception e) {
            System.err.println(e.getMessage());
        }
    }//GEN-LAST:event_jMenuItemChr13ActionPerformed

    private void jMenuItemChr14ActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_jMenuItemChr14ActionPerformed
        // TODO add your handling code here:
          
        String chr = "14";
        String figureFile = FIG_PATH + "AISAIC_chr_" + chr + ".png";
        try {
            Desktop.getDesktop().open(new File(figureFile));
        } catch (Exception e) {
            System.err.println(e.getMessage());
        }
    }//GEN-LAST:event_jMenuItemChr14ActionPerformed

    private void jMenuItemChr15ActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_jMenuItemChr15ActionPerformed
        // TODO add your handling code here:
          
        String chr = "15";
        String figureFile = FIG_PATH + "AISAIC_chr_" + chr + ".png";
        try {
            Desktop.getDesktop().open(new File(figureFile));
        } catch (Exception e) {
            System.err.println(e.getMessage());
        }
    }//GEN-LAST:event_jMenuItemChr15ActionPerformed

    private void jMenuItemChr16ActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_jMenuItemChr16ActionPerformed
        // TODO add your handling code here:
          
        String chr = "16";
        String figureFile = FIG_PATH + "AISAIC_chr_" + chr + ".png";
        try {
            Desktop.getDesktop().open(new File(figureFile));
        } catch (Exception e) {
            System.err.println(e.getMessage());
        }
    }//GEN-LAST:event_jMenuItemChr16ActionPerformed

    private void jMenuItemChr17ActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_jMenuItemChr17ActionPerformed
        // TODO add your handling code here:
          
        String chr = "17";
        String figureFile = FIG_PATH + "AISAIC_chr_" + chr + ".png";
        try {
            Desktop.getDesktop().open(new File(figureFile));
        } catch (Exception e) {
            System.err.println(e.getMessage());
        }
    }//GEN-LAST:event_jMenuItemChr17ActionPerformed

    private void jMenuItemChr18ActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_jMenuItemChr18ActionPerformed
        // TODO add your handling code here:
          
        String chr = "18";
        String figureFile = FIG_PATH + "AISAIC_chr_" + chr + ".png";
        try {
            Desktop.getDesktop().open(new File(figureFile));
        } catch (Exception e) {
            System.err.println(e.getMessage());
        }
    }//GEN-LAST:event_jMenuItemChr18ActionPerformed

    private void jMenuItemChr19ActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_jMenuItemChr19ActionPerformed
        // TODO add your handling code here:
          
        String chr = "19";
        String figureFile = FIG_PATH + "AISAIC_chr_" + chr + ".png";
        try {
            Desktop.getDesktop().open(new File(figureFile));
        } catch (Exception e) {
            System.err.println(e.getMessage());
        }
    }//GEN-LAST:event_jMenuItemChr19ActionPerformed

    private void jMenuItemChr20ActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_jMenuItemChr20ActionPerformed
        // TODO add your handling code here:
          
        String chr = "20";
        String figureFile = FIG_PATH + "AISAIC_chr_" + chr + ".png";
        try {
            Desktop.getDesktop().open(new File(figureFile));
        } catch (Exception e) {
            System.err.println(e.getMessage());
        }
    }//GEN-LAST:event_jMenuItemChr20ActionPerformed

    private void jMenuItemChr21ActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_jMenuItemChr21ActionPerformed
        // TODO add your handling code here:
          
        String chr = "21";
        String figureFile = FIG_PATH + "AISAIC_chr_" + chr + ".png";
        try {
            Desktop.getDesktop().open(new File(figureFile));
        } catch (Exception e) {
            System.err.println(e.getMessage());
        }
    }//GEN-LAST:event_jMenuItemChr21ActionPerformed

    private void jMenuItemChr22ActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_jMenuItemChr22ActionPerformed
        // TODO add your handling code here:
          
        String chr = "22";
        String figureFile = FIG_PATH + "AISAIC_chr_" + chr + ".png";
        try {
            Desktop.getDesktop().open(new File(figureFile));
        } catch (Exception e) {
            System.err.println(e.getMessage());
        }
    }//GEN-LAST:event_jMenuItemChr22ActionPerformed

    private void jMenuItemSingleChrVizActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_jMenuItemSingleChrVizActionPerformed
        // TODO add your handling code here:
          
        String chr = "";
        String figureFile = FIG_PATH + "AISAIC_singleChr.png";
        try {
            Desktop.getDesktop().open(new File(figureFile));
        } catch (Exception e) {
            System.err.println(e.getMessage());
        }
    }//GEN-LAST:event_jMenuItemSingleChrVizActionPerformed

    private void jMenuItemGenomeWideVizActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_jMenuItemGenomeWideVizActionPerformed
        // TODO add your handling code here:
          
        String chr = "genome";
        String figureFile = FIG_PATH + "AISAIC_genome.png";
        try {
            Desktop.getDesktop().open(new File(figureFile));
        } catch (Exception e) {
            System.err.println(e.getMessage());
        }
    }//GEN-LAST:event_jMenuItemGenomeWideVizActionPerformed

    /**
    * @param args the command line arguments
    */
    public static void main(String args[]) 
    {

        java.awt.EventQueue.invokeLater(new Runnable()
        {
            public void run()
            {
                AisaicGUI mySAICGUI = new AisaicGUI();
                mySAICGUI.setDefaultCloseOperation(EXIT_ON_CLOSE);
                mySAICGUI.setVisible(true);                
                mySAICGUI = null;
            }
        });
    }
    


    // Variables declaration - do not modify//GEN-BEGIN:variables
    private javax.swing.JPanel Data;
    private javax.swing.JPanel Data1;
    private javax.swing.JMenu JMenuHelp;
    private javax.swing.JButton jButton1;
    private javax.swing.JButton jButton10;
    private javax.swing.JButton jButton11;
    private javax.swing.JButton jButton2;
    private javax.swing.JButton jButton3;
    private javax.swing.JButton jButton4;
    private javax.swing.JButton jButton5;
    private javax.swing.JButton jButton6;
    private javax.swing.JButton jButton7;
    private javax.swing.JButton jButton8;
    private javax.swing.JButton jButton9;
    private javax.swing.JComboBox jComboBox1;
    private javax.swing.JComboBox jComboBox2;
    private javax.swing.JDialog jDialogAbout;
    private javax.swing.JLabel jLabel1;
    private javax.swing.JLabel jLabel10;
    private javax.swing.JLabel jLabel11;
    private javax.swing.JLabel jLabel12;
    private javax.swing.JLabel jLabel13;
    private javax.swing.JLabel jLabel14;
    private javax.swing.JLabel jLabel15;
    private javax.swing.JLabel jLabel16;
    private javax.swing.JLabel jLabel17;
    private javax.swing.JLabel jLabel18;
    private javax.swing.JLabel jLabel19;
    private javax.swing.JLabel jLabel2;
    private javax.swing.JLabel jLabel20;
    private javax.swing.JLabel jLabel3;
    private javax.swing.JLabel jLabel4;
    private javax.swing.JLabel jLabel5;
    private javax.swing.JLabel jLabel6;
    private javax.swing.JLabel jLabel7;
    private javax.swing.JLabel jLabel8;
    private javax.swing.JLabel jLabel9;
    private javax.swing.JMenuBar jMenuBar;
    private javax.swing.JMenu jMenuFile;
    private javax.swing.JMenuItem jMenuItemAbout;
    private javax.swing.JMenuItem jMenuItemChr1;
    private javax.swing.JMenuItem jMenuItemChr10;
    private javax.swing.JMenuItem jMenuItemChr11;
    private javax.swing.JMenuItem jMenuItemChr12;
    private javax.swing.JMenuItem jMenuItemChr13;
    private javax.swing.JMenuItem jMenuItemChr14;
    private javax.swing.JMenuItem jMenuItemChr15;
    private javax.swing.JMenuItem jMenuItemChr16;
    private javax.swing.JMenuItem jMenuItemChr17;
    private javax.swing.JMenuItem jMenuItemChr18;
    private javax.swing.JMenuItem jMenuItemChr19;
    private javax.swing.JMenuItem jMenuItemChr2;
    private javax.swing.JMenuItem jMenuItemChr20;
    private javax.swing.JMenuItem jMenuItemChr21;
    private javax.swing.JMenuItem jMenuItemChr22;
    private javax.swing.JMenuItem jMenuItemChr3;
    private javax.swing.JMenuItem jMenuItemChr4;
    private javax.swing.JMenuItem jMenuItemChr5;
    private javax.swing.JMenuItem jMenuItemChr6;
    private javax.swing.JMenuItem jMenuItemChr7;
    private javax.swing.JMenuItem jMenuItemChr8;
    private javax.swing.JMenuItem jMenuItemChr9;
    private javax.swing.JMenuItem jMenuItemExit;
    private javax.swing.JMenuItem jMenuItemGenomeWideViz;
    private javax.swing.JMenuItem jMenuItemSingleChrViz;
    private javax.swing.JMenu jMenuMultipleChrViz;
    private javax.swing.JMenu jMenuView;
    private javax.swing.JPanel jPanel1;
    private javax.swing.JRadioButton jRadioButton1;
    private javax.swing.JRadioButton jRadioButton2;
    private javax.swing.JRadioButton jRadioButton4;
    private javax.swing.JRadioButton jRadioButton6;
    private javax.swing.JRadioButton jRadioButton7;
    private javax.swing.JScrollPane jScrollPane2;
    private javax.swing.JTextArea jTextArea2;
    private javax.swing.JTextField jTextField1;
    private javax.swing.JTextField jTextField11;
    private javax.swing.JTextField jTextField12;
    private javax.swing.JTextField jTextField13;
    private javax.swing.JTextField jTextField14;
    private javax.swing.JTextField jTextField2;
    private javax.swing.JTextField jTextField3;
    private javax.swing.JTextField jTextField4;
    private javax.swing.JTextField jTextField5;
    private javax.swing.JTextField jTextField6;
    private javax.swing.JTextField jTextField7;
    private javax.swing.JTextField jTextField8;
    private javax.swing.JTextField jTextField9;
    // End of variables declaration//GEN-END:variables

}
